15
15
import csharp
16
16
import semmle.code.csharp.security.dataflow.flowsources.Remote
17
17
import semmle.code.csharp.commons.Util
18
- import DataFlow :: PathGraph
18
+ import AssemblyPathInjection :: PathGraph
19
19
20
20
/**
21
21
* A taint-tracking configuration for untrusted user input used to load a DLL.
22
22
*/
23
- class TaintTrackingConfiguration extends TaintTracking:: Configuration {
24
- TaintTrackingConfiguration ( ) { this = "DLLInjection" }
25
-
26
- override predicate isSource ( DataFlow:: Node source ) {
23
+ module AssemblyPathInjectionConfig implements DataFlow:: ConfigSig {
24
+ predicate isSource ( DataFlow:: Node source ) {
27
25
source instanceof RemoteFlowSource or
28
26
source .asExpr ( ) = any ( MainMethod main ) .getParameter ( 0 ) .getAnAccess ( )
29
27
}
30
28
31
- override predicate isSink ( DataFlow:: Node sink ) {
29
+ predicate isSink ( DataFlow:: Node sink ) {
32
30
exists ( MethodCall mc , string name , int arg |
33
31
mc .getTarget ( ) .getName ( ) .matches ( name ) and
34
32
mc .getTarget ( )
@@ -48,7 +46,12 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
48
46
}
49
47
}
50
48
51
- from TaintTrackingConfiguration c , DataFlow:: PathNode source , DataFlow:: PathNode sink
52
- where c .hasFlowPath ( source , sink )
49
+ /**
50
+ * A taint-tracking module for untrusted user input used to load a DLL.
51
+ */
52
+ module AssemblyPathInjection = TaintTracking:: Global< AssemblyPathInjectionConfig > ;
53
+
54
+ from AssemblyPathInjection:: PathNode source , AssemblyPathInjection:: PathNode sink
55
+ where AssemblyPathInjection:: flowPath ( source , sink )
53
56
select sink .getNode ( ) , source , sink , "This assembly path depends on a $@." , source ,
54
57
"user-provided value"
0 commit comments