-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathResponseSplitting.qll
More file actions
38 lines (36 loc) · 1.09 KB
/
ResponseSplitting.qll
File metadata and controls
38 lines (36 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import java
import semmle.code.java.frameworks.Servlets
import semmle.code.java.dataflow.FlowSources
/**
* Header-splitting sinks. Expressions that end up in an HTTP header.
*/
class HeaderSplittingSink extends DataFlow::ExprNode {
HeaderSplittingSink() {
exists(ResponseAddCookieMethod m, MethodAccess ma |
ma.getMethod() = m and
this.getExpr() = ma.getArgument(0)
)
or
exists(ResponseAddHeaderMethod m, MethodAccess ma |
ma.getMethod() = m and
this.getExpr() = ma.getAnArgument()
)
or
exists(ResponseSetHeaderMethod m, MethodAccess ma |
ma.getMethod() = m and
this.getExpr() = ma.getAnArgument()
)
or
exists(JaxRsResponseBuilder builder, Method m |
m = builder.getAMethod() and m.getName() = "header"
|
this.getExpr() = m.getAReference().getArgument(1)
)
}
}
class WhitelistedSource extends DataFlow::ExprNode {
WhitelistedSource() {
this.asExpr().(MethodAccess).getMethod() instanceof HttpServletRequestGetHeaderMethod or
this.asExpr().(MethodAccess).getMethod() instanceof CookieGetNameMethod
}
}