Skip to content

Commit 1d716ae

Browse files
committed
Java: Add remote user input sources for Spring servlets.
1 parent c78f3f8 commit 1d716ae

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

change-notes/1.19/analysis-java.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,9 @@
1717

1818
## Changes to QL libraries
1919

20+
* The default set of taint sources in the `FlowSources` library is extended to
21+
cover parameters annotated with Spring framework annotations indicating
22+
remote user input from servlets. This affects all security queries, which
23+
will yield additional results on projects using the Spring Web framework.
2024
* The `ParityAnalysis` library is replaced with the more general `ModulusAnalysis` library, which improves the range analysis.
2125

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import semmle.code.java.frameworks.android.XmlParsing
1616
import semmle.code.java.frameworks.android.WebView
1717
import semmle.code.java.frameworks.JaxWS
1818
import semmle.code.java.frameworks.android.Intent
19+
import semmle.code.java.frameworks.SpringWeb
1920

2021
/** Class for `tainted` user input. */
2122
abstract class UserInput extends DataFlow::Node { }
@@ -66,6 +67,8 @@ class RemoteUserInput extends UserInput {
6667
m.getParameter(4) = this.asParameter() or
6768
m.getParameter(5) = this.asParameter()
6869
)
70+
or
71+
this.asParameter().getAnAnnotation() instanceof SpringServletInputAnnotation
6972
}
7073

7174
/**
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import java
2+
3+
/** A Spring framework annotation indicating remote user input from servlets. */
4+
class SpringServletInputAnnotation extends Annotation {
5+
SpringServletInputAnnotation() {
6+
exists(AnnotationType a |
7+
a = this.getType() and
8+
a.getPackage().getName() = "org.springframework.web.bind.annotation"
9+
|
10+
a.hasName("MatrixVariable") or
11+
a.hasName("RequestParam") or
12+
a.hasName("RequestHeader") or
13+
a.hasName("CookieValue") or
14+
a.hasName("RequestPart")
15+
)
16+
}
17+
}

0 commit comments

Comments
 (0)