@@ -3,11 +3,20 @@ private import codeql.actions.TaintTracking
33private import codeql.actions.dataflow.ExternalFlow
44import codeql.actions.dataflow.FlowSources
55import codeql.actions.DataFlow
6+ import codeql.actions.security.ControlChecks
67
78private class CommandInjectionSink extends DataFlow:: Node {
89 CommandInjectionSink ( ) { madSink ( this , "command-injection" ) }
910}
1011
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+
1120/**
1221 * A taint-tracking configuration for unsafe user input
1322 * that is used to construct and evaluate a system command.
@@ -16,6 +25,16 @@ private module CommandInjectionConfig implements DataFlow::ConfigSig {
1625 predicate isSource ( DataFlow:: Node source ) { source instanceof RemoteFlowSource }
1726
1827 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+ }
1938}
2039
2140/** Tracks flow of unsafe user input that is used to construct and evaluate a system command. */
0 commit comments