Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 731cae4

Browse files
authored
Merge pull request #193 from advanced-security/securingdev-java-cwe-611-dataflow-udpate-2
Securingdev java CWE 611 dataflow
2 parents 3d8ba64 + d849918 commit 731cae4

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

java/CWE-611/XXELocal.ql

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ import semmle.code.java.dataflow.TaintTracking2
2020
//import DataFlow::PathGraph
2121
import github.LocalSources
2222

23-
class SafeSAXSourceFlowConfig extends TaintTracking2::Configuration {
24-
SafeSAXSourceFlowConfig() { this = "XmlParsers::SafeSAXSourceFlowConfig" }
23+
module SafeSAXSourceFlowConfig implements DataFlow::ConfigSig {
24+
predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSaxSource }
2525

26-
override predicate isSource(DataFlow::Node src) { src.asExpr() instanceof SafeSaxSource }
27-
28-
override predicate isSink(DataFlow::Node sink) {
26+
predicate isSink(DataFlow::Node sink) {
2927
sink.asExpr() = any(XmlParserCall parse).getSink()
3028
}
3129

32-
override int fieldFlowBranchLimit() { result = 0 }
30+
int fieldFlowBranchLimit() { result = 0 }
3331
}
3432

33+
module SafeSAXSourceFlow = TaintTracking::Global<SafeSAXSourceFlowConfig>;
34+
3535
class UnsafeXxeSink extends DataFlow::ExprNode {
3636
UnsafeXxeSink() {
37-
not exists(SafeSAXSourceFlowConfig safeSource | safeSource.hasFlowTo(this)) and
37+
not SafeSAXSourceFlow::flowTo(this) and
3838
exists(XmlParserCall parse |
3939
parse.getSink() = this.getExpr() and
4040
not parse.isSafe()
@@ -43,7 +43,9 @@ class UnsafeXxeSink extends DataFlow::ExprNode {
4343
}
4444

4545
module XXELocalConfig implements DataFlow::ConfigSig {
46-
predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput }
46+
predicate isSource(DataFlow::Node source) {
47+
source instanceof LocalUserInput and
48+
not exists(DataFlow::Node src | src.asExpr() instanceof SafeSaxSource)}
4749

4850
predicate isSink(DataFlow::Node sink) { sink instanceof UnsafeXxeSink }
4951
}

0 commit comments

Comments
 (0)