File tree Expand file tree Collapse file tree
python/ql/src/experimental/Security/CWE-614 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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."
You can’t perform that action at this time.
0 commit comments