Java: Add remote user input sources for Spring servlets.

This commit is contained in:
Anders Schack-Mulligen
2018-10-24 14:54:42 +02:00
parent c78f3f8edf
commit 1d716ae461
3 changed files with 24 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ import semmle.code.java.frameworks.android.XmlParsing
import semmle.code.java.frameworks.android.WebView
import semmle.code.java.frameworks.JaxWS
import semmle.code.java.frameworks.android.Intent
import semmle.code.java.frameworks.SpringWeb
/** Class for `tainted` user input. */
abstract class UserInput extends DataFlow::Node { }
@@ -66,6 +67,8 @@ class RemoteUserInput extends UserInput {
m.getParameter(4) = this.asParameter() or
m.getParameter(5) = this.asParameter()
)
or
this.asParameter().getAnAnnotation() instanceof SpringServletInputAnnotation
}
/**

View File

@@ -0,0 +1,17 @@
import java
/** A Spring framework annotation indicating remote user input from servlets. */
class SpringServletInputAnnotation extends Annotation {
SpringServletInputAnnotation() {
exists(AnnotationType a |
a = this.getType() and
a.getPackage().getName() = "org.springframework.web.bind.annotation"
|
a.hasName("MatrixVariable") or
a.hasName("RequestParam") or
a.hasName("RequestHeader") or
a.hasName("CookieValue") or
a.hasName("RequestPart")
)
}
}