File tree Expand file tree Collapse file tree 1 file changed +6
-13
lines changed
java/ql/src/experimental/Security/CWE/CWE-1004 Expand file tree Collapse file tree 1 file changed +6
-13
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,10 @@ predicate setHttpOnlyInCookie(MethodAccess ma) {
9797class SetHttpOnlyInCookieConfiguration extends TaintTracking2:: Configuration {
9898 SetHttpOnlyInCookieConfiguration ( ) { this = "SetHttpOnlyInCookieConfiguration" }
9999
100- override predicate isSource ( DataFlow:: Node source ) { any ( ) }
100+ override predicate isSource ( DataFlow:: Node source ) {
101+ source .asExpr ( ) =
102+ any ( MethodAccess ma | setHttpOnlyInCookie ( ma ) or removeCookie ( ma ) ) .getQualifier ( )
103+ }
101104
102105 override predicate isSink ( DataFlow:: Node sink ) {
103106 sink .asExpr ( ) =
@@ -123,21 +126,11 @@ class CookieResponseSink extends DataFlow::ExprNode {
123126 (
124127 ma .getMethod ( ) instanceof ResponseAddCookieMethod and
125128 this .getExpr ( ) = ma .getArgument ( 0 ) and
126- not exists (
127- MethodAccess ma2 // a method or wrapper method that invokes cookie.setHttpOnly(true)
128- |
129- (
130- setHttpOnlyInCookie ( ma2 ) or
131- removeCookie ( ma2 )
132- ) and
133- exists ( SetHttpOnlyInCookieConfiguration cc |
134- cc .hasFlow ( DataFlow:: exprNode ( ma2 .getQualifier ( ) ) , this )
135- )
136- )
129+ not exists ( SetHttpOnlyInCookieConfiguration cc | cc .hasFlowTo ( this ) )
137130 or
138131 ma instanceof SetCookieMethodAccess and
139132 this .getExpr ( ) = ma .getArgument ( 1 ) and
140- not exists ( MatchesHttpOnlyConfiguration cc | cc .hasFlowToExpr ( ma . getArgument ( 1 ) ) ) // response.addHeader("Set-Cookie", "token=" +authId + ";HttpOnly;Secure")
133+ not exists ( MatchesHttpOnlyConfiguration cc | cc .hasFlowTo ( this ) ) // response.addHeader("Set-Cookie", "token=" +authId + ";HttpOnly;Secure")
141134 ) and
142135 not isTestMethod ( ma ) // Test class or method
143136 )
You can’t perform that action at this time.
0 commit comments