Skip to content

Commit cbc2d9e

Browse files
authored
Merge pull request #361 from aschackmull/java/springweb-servlet-sources
Approved by yh-semmle
2 parents 9059110 + 1d716ae commit cbc2d9e

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
@@ -19,5 +19,9 @@
1919

2020
## Changes to QL libraries
2121

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

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)