1515import csharp
1616import semmle.code.csharp.security.dataflow.flowsources.Remote
1717import semmle.code.csharp.commons.Util
18- import DataFlow :: PathGraph
18+ import AssemblyPathInjection :: PathGraph
1919
2020/**
2121 * A taint-tracking configuration for untrusted user input used to load a DLL.
2222 */
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 ) {
2725 source instanceof RemoteFlowSource or
2826 source .asExpr ( ) = any ( MainMethod main ) .getParameter ( 0 ) .getAnAccess ( )
2927 }
3028
31- override predicate isSink ( DataFlow:: Node sink ) {
29+ predicate isSink ( DataFlow:: Node sink ) {
3230 exists ( MethodCall mc , string name , int arg |
3331 mc .getTarget ( ) .getName ( ) .matches ( name ) and
3432 mc .getTarget ( )
@@ -48,7 +46,12 @@ class TaintTrackingConfiguration extends TaintTracking::Configuration {
4846 }
4947}
5048
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 )
5356select sink .getNode ( ) , source , sink , "This assembly path depends on a $@." , source ,
5457 "user-provided value"
0 commit comments