Skip to content

Commit 17fd758

Browse files
committed
Java: Convert XSS sinks to CSV format
1 parent 0b7a667 commit 17fd758

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

java/ql/src/semmle/code/java/dataflow/ExternalFlow.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ private module Frameworks {
7777
private import semmle.code.java.frameworks.apache.Lang
7878
private import semmle.code.java.frameworks.guava.Guava
7979
private import semmle.code.java.security.ResponseSplitting
80+
private import semmle.code.java.security.XSS
8081
}
8182

8283
private predicate sourceModelCsv(string row) {

java/ql/src/semmle/code/java/security/XSS.qll

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,29 @@ class XssAdditionalTaintStep extends Unit {
2929
abstract predicate step(DataFlow::Node node1, DataFlow::Node node2);
3030
}
3131

32+
private class DefaultXssSinkModel extends SinkModelCsv {
33+
override predicate row(string row) {
34+
row =
35+
[
36+
"javax.servlet.http;HttpServletResponse;false;sendError;(int,String);;Argument[1];xss",
37+
"android.webkit;WebView;false;loadData;;;Argument[0];xss",
38+
"android.webkit;WebView;false;loadUrl;;;Argument[0];xss",
39+
"android.webkit;WebView;false;loadDataWithBaseURL;;;Argument[1];xss"
40+
]
41+
}
42+
}
43+
3244
/** A default sink representing methods susceptible to XSS attacks. */
3345
private class DefaultXssSink extends XssSink {
3446
DefaultXssSink() {
3547
sinkNode(this, "xss")
3648
or
37-
exists(HttpServletResponseSendErrorMethod m, MethodAccess ma |
38-
ma.getMethod() = m and
39-
this.asExpr() = ma.getArgument(1)
40-
)
41-
or
4249
exists(ServletWriterSourceToWritingMethodFlowConfig writer, MethodAccess ma |
4350
ma.getMethod() instanceof WritingMethod and
4451
writer.hasFlowToExpr(ma.getQualifier()) and
4552
this.asExpr() = ma.getArgument(_)
4653
)
4754
or
48-
exists(Method m |
49-
m.getDeclaringType() instanceof TypeWebView and
50-
(
51-
m.getAReference().getArgument(0) = this.asExpr() and m.getName() = "loadData"
52-
or
53-
m.getAReference().getArgument(0) = this.asExpr() and m.getName() = "loadUrl"
54-
or
55-
m.getAReference().getArgument(1) = this.asExpr() and m.getName() = "loadDataWithBaseURL"
56-
)
57-
)
58-
or
5955
exists(SpringRequestMappingMethod requestMappingMethod, ReturnStmt rs |
6056
requestMappingMethod = rs.getEnclosingCallable() and
6157
this.asExpr() = rs.getResult() and

0 commit comments

Comments
 (0)