@@ -8,48 +8,49 @@ private import semmle.code.java.dataflow.StringPrefixes
88/** A URL forward sink. */
99abstract class UrlForwardSink extends DataFlow:: Node { }
1010
11- /** A default sink representing methods susceptible to URL forwarding attacks. */
11+ /**
12+ * A default sink representing methods susceptible to URL
13+ * forwarding attacks.
14+ */
1215private class DefaultUrlForwardSink extends UrlForwardSink {
1316 DefaultUrlForwardSink ( ) { sinkNode ( this , "url-forward" ) }
1417}
1518
1619/**
17- * An expression appended (perhaps indirectly) to `"forward:"`, and which
18- * is reachable from a Spring entry point.
20+ * An expression appended (perhaps indirectly) to `"forward:"`
21+ * and reachable from a Spring entry point.
1922 */
2023private class SpringUrlForwardSink extends UrlForwardSink {
2124 SpringUrlForwardSink ( ) {
22- // TODO: check if can use MaD "Annotated" for `SpringRequestMappingMethod` or if too complicated for MaD (probably too complicated).
23- any ( SpringRequestMappingMethod sqmm ) .polyCalls * ( this .getEnclosingCallable ( ) ) and
25+ any ( SpringRequestMappingMethod srmm ) .polyCalls * ( this .getEnclosingCallable ( ) ) and
2426 this .asExpr ( ) = any ( ForwardPrefix fp ) .getAnAppendedExpression ( )
2527 }
2628}
2729
28- // TODO: should this potentially be "include:" as well? Or does that not work similarly?
2930private class ForwardPrefix extends InterestingPrefix {
3031 ForwardPrefix ( ) { this .getStringValue ( ) = "forward:" }
3132
3233 override int getOffset ( ) { result = 0 }
3334}
3435
35- /** A URL forward sanitizer . */
36- abstract class UrlForwardSanitizer extends DataFlow:: Node { }
36+ /** A URL forward barrier . */
37+ abstract class UrlForwardBarrier extends DataFlow:: Node { }
3738
38- private class PrimitiveSanitizer extends UrlForwardSanitizer {
39- PrimitiveSanitizer ( ) {
39+ private class PrimitiveBarrier extends UrlForwardBarrier {
40+ PrimitiveBarrier ( ) {
4041 this .getType ( ) instanceof PrimitiveType or
4142 this .getType ( ) instanceof BoxedType or
4243 this .getType ( ) instanceof NumberType
4344 }
4445}
4546
46- // TODO: double-check this sanitizer (and should I switch all "sanitizer" naming to "barrier" instead?)
47- private class FollowsSanitizingPrefix extends UrlForwardSanitizer {
48- FollowsSanitizingPrefix ( ) { this .asExpr ( ) = any ( SanitizingPrefix fp ) .getAnAppendedExpression ( ) }
47+ private class FollowsBarrierPrefix extends UrlForwardBarrier {
48+ FollowsBarrierPrefix ( ) { this .asExpr ( ) = any ( BarrierPrefix fp ) .getAnAppendedExpression ( ) }
4949}
5050
51- private class SanitizingPrefix extends InterestingPrefix {
52- SanitizingPrefix ( ) {
51+ private class BarrierPrefix extends InterestingPrefix {
52+ BarrierPrefix ( ) {
53+ // TODO: why not META-INF here as well? (and are `/` correct?)
5354 not this .getStringValue ( ) .matches ( "/WEB-INF/%" ) and
5455 not this .getStringValue ( ) = "forward:"
5556 }
0 commit comments