12
12
*/
13
13
14
14
import csharp
15
- import DataFlow:: PathGraph
16
15
import semmle.code.csharp.security.dataflow.flowsources.Remote
17
16
import semmle.code.csharp.frameworks.system.Xml
17
+ import XmlInjection:: PathGraph
18
18
19
19
/**
20
20
* A taint-tracking configuration for untrusted user input used in XML.
21
21
*/
22
- class TaintTrackingConfiguration extends TaintTracking :: Configuration {
23
- TaintTrackingConfiguration ( ) { this = "XMLInjection" }
22
+ module XmlInjectionConfig implements DataFlow :: ConfigSig {
23
+ predicate isSource ( DataFlow :: Node source ) { source instanceof RemoteFlowSource }
24
24
25
- override predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
26
-
27
- override predicate isSink ( DataFlow:: Node sink ) {
25
+ predicate isSink ( DataFlow:: Node sink ) {
28
26
exists ( MethodCall mc |
29
27
mc .getTarget ( ) .hasName ( "WriteRaw" ) and
30
28
mc .getTarget ( ) .getDeclaringType ( ) .getABaseType * ( ) .hasQualifiedName ( "System.Xml" , "XmlWriter" )
@@ -33,7 +31,7 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
33
31
)
34
32
}
35
33
36
- override predicate isSanitizer ( DataFlow:: Node node ) {
34
+ predicate isBarrier ( DataFlow:: Node node ) {
37
35
exists ( MethodCall mc |
38
36
mc .getTarget ( ) .hasName ( "Escape" ) and
39
37
mc .getTarget ( )
@@ -46,7 +44,12 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
46
44
}
47
45
}
48
46
49
- from TaintTrackingConfiguration c , DataFlow:: PathNode source , DataFlow:: PathNode sink
50
- where c .hasFlowPath ( source , sink )
47
+ /**
48
+ * A taint-tracking module for untrusted user input used in XML.
49
+ */
50
+ module XmlInjection = TaintTracking:: Global< XmlInjectionConfig > ;
51
+
52
+ from XmlInjection:: PathNode source , XmlInjection:: PathNode sink
53
+ where XmlInjection:: flowPath ( source , sink )
51
54
select sink .getNode ( ) , source , sink , "This XML element depends on a $@." , source .getNode ( ) ,
52
55
"user-provided value"
0 commit comments