1- /** Provides taint tracking configurations to be used in XXE queries. */
1+ /** Provides default definitions to be used in XXE queries. */
22
33import java
4- import semmle.code.java.dataflow.FlowSources
5- import semmle.code.java.dataflow.TaintTracking
6- import semmle.code.java.dataflow.TaintTracking2
7- import semmle.code.java.security.XmlParsers
4+ private import semmle.code.java.dataflow.TaintTracking2
5+ import semmle.code.java.security.Xxe
86
97/**
10- * A taint-tracking configuration for unvalidated remote user input that is used in XML external entity expansion.
8+ * The default implementation of a XXE sink.
9+ * The argument of a parse call on an insecurely configured XML parser.
1110 */
12- class XxeConfig extends TaintTracking:: Configuration {
13- XxeConfig ( ) { this = "XxeConfig" }
14-
15- override predicate isSource ( DataFlow:: Node src ) { src instanceof RemoteFlowSource }
16-
17- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof UnsafeXxeSink }
18- }
19-
20- /**
21- * A taint-tracking configuration for unvalidated local user input that is used in XML external entity expansion.
22- */
23- class XxeLocalConfig extends TaintTracking:: Configuration {
24- XxeLocalConfig ( ) { this = "XxeLocalConfig" }
25-
26- override predicate isSource ( DataFlow:: Node src ) { src instanceof LocalUserInput }
27-
28- override predicate isSink ( DataFlow:: Node sink ) { sink instanceof UnsafeXxeSink }
29- }
30-
31- private class UnsafeXxeSink extends DataFlow:: ExprNode {
32- UnsafeXxeSink ( ) {
11+ private class DefaultXxeSink extends XxeSink {
12+ DefaultXxeSink ( ) {
3313 not exists ( SafeSaxSourceFlowConfig safeSource | safeSource .hasFlowTo ( this ) ) and
3414 exists ( XmlParserCall parse |
35- parse .getSink ( ) = this .getExpr ( ) and
15+ parse .getSink ( ) = this .asExpr ( ) and
3616 not parse .isSafe ( )
3717 )
3818 }
@@ -42,7 +22,7 @@ private class UnsafeXxeSink extends DataFlow::ExprNode {
4222 * A taint-tracking configuration for safe XML readers used to parse XML documents.
4323 */
4424private class SafeSaxSourceFlowConfig extends TaintTracking2:: Configuration {
45- SafeSaxSourceFlowConfig ( ) { this = "XmlParsers::SafeSAXSourceFlowConfig " }
25+ SafeSaxSourceFlowConfig ( ) { this = "SafeSaxSourceFlowConfig " }
4626
4727 override predicate isSource ( DataFlow:: Node src ) { src .asExpr ( ) instanceof SafeSaxSource }
4828
0 commit comments