Skip to content

Commit 1fc58e5

Browse files
author
luciaromeroML
committed
adding suggestion that removes sanitizer for unknown base urls
1 parent 1f2618b commit 1fc58e5

File tree

1 file changed

+15
-1
lines changed
  • javascript/ql/src/experimental/Security/CWE-918

1 file changed

+15
-1
lines changed

javascript/ql/src/experimental/Security/CWE-918/SSRF.qll

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,22 @@ class Configuration extends TaintTracking::Configuration {
1414
node instanceof RequestForgery::Sanitizer
1515
}
1616

17+
private predicate hasSanitizingSubstring(DataFlow::Node nd) {
18+
nd.getStringValue().regexpMatch(".*[?#].*")
19+
or
20+
hasSanitizingSubstring(StringConcatenation::getAnOperand(nd))
21+
or
22+
hasSanitizingSubstring(nd.getAPredecessor())
23+
}
24+
25+
private predicate strictSanitizingPrefixEdge(DataFlow::Node source, DataFlow::Node sink) {
26+
exists(DataFlow::Node operator, int n |
27+
StringConcatenation::taintStep(source, sink, operator, n) and
28+
hasSanitizingSubstring(StringConcatenation::getOperand(operator, [0 .. n - 1]))
29+
)
30+
}
1731
override predicate isSanitizerEdge(DataFlow::Node source, DataFlow::Node sink) {
18-
sanitizingPrefixEdge(source, sink)
32+
strictSanitizingPrefixEdge(source, sink)
1933
}
2034

2135
override predicate isSanitizerGuard(TaintTracking::SanitizerGuardNode nd) {

0 commit comments

Comments
 (0)