Skip to content

Commit 5fa63ab

Browse files
Jami CogswellJami Cogswell
authored andcommitted
Java: update/add some TODO comments
1 parent c331393 commit 5fa63ab

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

java/ql/lib/semmle/code/java/security/UrlForward.qll

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,49 @@ private import semmle.code.java.dataflow.StringPrefixes
88
/** A URL forward sink. */
99
abstract 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+
*/
1215
private 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
*/
2023
private 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?
2930
private 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
}

java/ql/lib/semmle/code/java/security/UrlForwardQuery.qll

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,24 @@ import semmle.code.java.security.PathSanitizer
1212
module UrlForwardFlowConfig implements DataFlow::ConfigSig {
1313
predicate isSource(DataFlow::Node source) {
1414
source instanceof ThreatModelFlowSource and
15-
// TODO: move below logic to class in UrlForward.qll? And check exactly why these were excluded.
16-
not exists(MethodCall ma, Method m | ma.getMethod() = m |
15+
// excluded due to FPs
16+
not exists(MethodCall mc, Method m | mc.getMethod() = m |
1717
(
1818
m instanceof HttpServletRequestGetRequestUriMethod or
1919
m instanceof HttpServletRequestGetRequestUrlMethod or
2020
m instanceof HttpServletRequestGetPathMethod
2121
) and
22-
ma = source.asExpr()
22+
mc = source.asExpr()
2323
)
2424
}
2525

2626
predicate isSink(DataFlow::Node sink) { sink instanceof UrlForwardSink }
2727

2828
predicate isBarrier(DataFlow::Node node) {
29-
node instanceof UrlForwardSanitizer or
29+
node instanceof UrlForwardBarrier or
3030
node instanceof PathInjectionSanitizer
3131
}
3232

33-
// TODO: check if the below is still needed after removing path-injection related sinks.
3433
DataFlow::FlowFeature getAFeature() { result instanceof DataFlow::FeatureHasSourceCallContext }
3534
}
3635

0 commit comments

Comments
 (0)