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) {
97
97
class SetHttpOnlyInCookieConfiguration extends TaintTracking2:: Configuration {
98
98
SetHttpOnlyInCookieConfiguration ( ) { this = "SetHttpOnlyInCookieConfiguration" }
99
99
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
+ }
101
104
102
105
override predicate isSink ( DataFlow:: Node sink ) {
103
106
sink .asExpr ( ) =
@@ -123,21 +126,11 @@ class CookieResponseSink extends DataFlow::ExprNode {
123
126
(
124
127
ma .getMethod ( ) instanceof ResponseAddCookieMethod and
125
128
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 ) )
137
130
or
138
131
ma instanceof SetCookieMethodAccess and
139
132
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")
141
134
) and
142
135
not isTestMethod ( ma ) // Test class or method
143
136
)
You can’t perform that action at this time.
0 commit comments