Skip to content

Commit c8983be

Browse files
committed
Add query
1 parent 8a3e4f1 commit c8983be

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* @name Failure to use secure cookies
3+
* @description Insecure cookies may be sent in cleartext, which makes them vulnerable to
4+
* interception.
5+
* @kind problem
6+
* @problem.severity error
7+
* @id py/insecure-cookie
8+
* @tags security
9+
* external/cwe/cwe-614
10+
*/
11+
12+
// determine precision above
13+
import python
14+
import semmle.python.dataflow.new.DataFlow
15+
import semmle.python.Concepts
16+
import experimental.semmle.python.Concepts
17+
18+
from HeaderDeclaration headerWrite, False f, None n
19+
where
20+
exists(StrConst headerName, StrConst headerValue |
21+
headerName.getText() = "Set-Cookie" and
22+
DataFlow::exprNode(headerName).(DataFlow::LocalSourceNode).flowsTo(headerWrite.getNameArg()) and
23+
not headerValue.getText().regexpMatch(".*; *Secure;.*") and
24+
DataFlow::exprNode(headerValue).(DataFlow::LocalSourceNode).flowsTo(headerWrite.getValueArg())
25+
)
26+
or
27+
[DataFlow::exprNode(f), DataFlow::exprNode(n)]
28+
.(DataFlow::LocalSourceNode)
29+
.flowsTo(headerWrite.(DataFlow::CallCfgNode).getArgByName("secure"))
30+
select headerWrite, "Cookie is added to response without the 'secure' flag being set."

0 commit comments

Comments
 (0)