@@ -8,48 +8,49 @@ private import semmle.code.java.dataflow.StringPrefixes
8
8
/** A URL forward sink. */
9
9
abstract class UrlForwardSink extends DataFlow:: Node { }
10
10
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
+ */
12
15
private class DefaultUrlForwardSink extends UrlForwardSink {
13
16
DefaultUrlForwardSink ( ) { sinkNode ( this , "url-forward" ) }
14
17
}
15
18
16
19
/**
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.
19
22
*/
20
23
private class SpringUrlForwardSink extends UrlForwardSink {
21
24
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
24
26
this .asExpr ( ) = any ( ForwardPrefix fp ) .getAnAppendedExpression ( )
25
27
}
26
28
}
27
29
28
- // TODO: should this potentially be "include:" as well? Or does that not work similarly?
29
30
private class ForwardPrefix extends InterestingPrefix {
30
31
ForwardPrefix ( ) { this .getStringValue ( ) = "forward:" }
31
32
32
33
override int getOffset ( ) { result = 0 }
33
34
}
34
35
35
- /** A URL forward sanitizer . */
36
- abstract class UrlForwardSanitizer extends DataFlow:: Node { }
36
+ /** A URL forward barrier . */
37
+ abstract class UrlForwardBarrier extends DataFlow:: Node { }
37
38
38
- private class PrimitiveSanitizer extends UrlForwardSanitizer {
39
- PrimitiveSanitizer ( ) {
39
+ private class PrimitiveBarrier extends UrlForwardBarrier {
40
+ PrimitiveBarrier ( ) {
40
41
this .getType ( ) instanceof PrimitiveType or
41
42
this .getType ( ) instanceof BoxedType or
42
43
this .getType ( ) instanceof NumberType
43
44
}
44
45
}
45
46
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 ( ) }
49
49
}
50
50
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?)
53
54
not this .getStringValue ( ) .matches ( "/WEB-INF/%" ) and
54
55
not this .getStringValue ( ) = "forward:"
55
56
}
0 commit comments