@@ -3,11 +3,20 @@ private import codeql.actions.TaintTracking
3
3
private import codeql.actions.dataflow.ExternalFlow
4
4
import codeql.actions.dataflow.FlowSources
5
5
import codeql.actions.DataFlow
6
+ import codeql.actions.security.ControlChecks
6
7
7
8
private class CommandInjectionSink extends DataFlow:: Node {
8
9
CommandInjectionSink ( ) { madSink ( this , "command-injection" ) }
9
10
}
10
11
12
+ /** Get the relevant event for the sink in CommandInjectionCritical.ql. */
13
+ Event getRelevantEventInPrivilegedContext ( DataFlow:: Node sink ) {
14
+ inPrivilegedContext ( sink .asExpr ( ) , result ) and
15
+ not exists ( ControlCheck check |
16
+ check .protects ( sink .asExpr ( ) , result , [ "command-injection" , "code-injection" ] )
17
+ )
18
+ }
19
+
11
20
/**
12
21
* A taint-tracking configuration for unsafe user input
13
22
* that is used to construct and evaluate a system command.
@@ -16,6 +25,16 @@ private module CommandInjectionConfig implements DataFlow::ConfigSig {
16
25
predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
17
26
18
27
predicate isSink ( DataFlow:: Node sink ) { sink instanceof CommandInjectionSink }
28
+
29
+ predicate observeDiffInformedIncrementalMode ( ) { any ( ) }
30
+
31
+ Location getASelectedSourceLocation ( DataFlow:: Node source ) { none ( ) }
32
+
33
+ Location getASelectedSinkLocation ( DataFlow:: Node sink ) {
34
+ result = sink .getLocation ( )
35
+ or
36
+ result = getRelevantEventInPrivilegedContext ( sink ) .getLocation ( )
37
+ }
19
38
}
20
39
21
40
/** Tracks flow of unsafe user input that is used to construct and evaluate a system command. */
0 commit comments