Skip to content

Commit 3102199

Browse files
committed
Make LocalUserInputToArgumentToExecFlowConfig and LocalUserInputToArgumentToExecFlow importable
1 parent 534725f commit 3102199

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed

java/ql/lib/semmle/code/java/security/CommandLineQuery.qll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,27 @@ module RemoteUserInputToArgumentToExecFlowConfig implements DataFlow::ConfigSig
6969
module RemoteUserInputToArgumentToExecFlow =
7070
TaintTracking::Global<RemoteUserInputToArgumentToExecFlowConfig>;
7171

72+
/**
73+
* A taint-tracking configuration for unvalidated local user input that is used to run an external process.
74+
*/
75+
module LocalUserInputToArgumentToExecFlowConfig implements DataFlow::ConfigSig {
76+
predicate isSource(DataFlow::Node src) { src instanceof LocalUserInput }
77+
78+
predicate isSink(DataFlow::Node sink) { sink instanceof CommandInjectionSink }
79+
80+
predicate isBarrier(DataFlow::Node node) { node instanceof CommandInjectionSanitizer }
81+
82+
predicate isAdditionalFlowStep(DataFlow::Node n1, DataFlow::Node n2) {
83+
any(CommandInjectionAdditionalTaintStep s).step(n1, n2)
84+
}
85+
}
86+
87+
/**
88+
* Taint-tracking flow for unvalidated local user input that is used to run an external process.
89+
*/
90+
module LocalUserInputToArgumentToExecFlow =
91+
TaintTracking::Global<LocalUserInputToArgumentToExecFlowConfig>;
92+
7293
/**
7394
* Implementation of `ExecTainted.ql`. It is extracted to a QLL
7495
* so that it can be excluded from `ExecUnescaped.ql` to avoid

java/ql/src/Security/CWE/CWE-078/ExecTaintedLocal.ql

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,12 @@
1212
* external/cwe/cwe-088
1313
*/
1414

15-
import semmle.code.java.Expr
16-
import semmle.code.java.dataflow.FlowSources
17-
import semmle.code.java.security.ExternalProcess
18-
import semmle.code.java.security.CommandArguments
19-
20-
module LocalUserInputToArgumentToExecFlowConfig implements DataFlow::ConfigSig {
21-
predicate isSource(DataFlow::Node src) { src instanceof LocalUserInput }
22-
23-
predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof ArgumentToExec }
24-
25-
predicate isBarrier(DataFlow::Node node) {
26-
node.getType() instanceof PrimitiveType
27-
or
28-
node.getType() instanceof BoxedType
29-
or
30-
isSafeCommandArgument(node.asExpr())
31-
}
32-
}
33-
34-
module LocalUserInputToArgumentToExecFlow =
35-
TaintTracking::Global<LocalUserInputToArgumentToExecFlowConfig>;
36-
15+
import semmle.code.java.security.CommandLineQuery
3716
import LocalUserInputToArgumentToExecFlow::PathGraph
3817

3918
from
4019
LocalUserInputToArgumentToExecFlow::PathNode source,
41-
LocalUserInputToArgumentToExecFlow::PathNode sink, ArgumentToExec execArg
42-
where
43-
LocalUserInputToArgumentToExecFlow::flowPath(source, sink) and
44-
sink.getNode().asExpr() = execArg
45-
select execArg, source, sink, "This command line depends on a $@.", source.getNode(),
46-
"user-provided value"
20+
LocalUserInputToArgumentToExecFlow::PathNode sink
21+
where LocalUserInputToArgumentToExecFlow::flowPath(source, sink)
22+
select sink.getNode().asExpr(), source, sink, "This command line depends on a $@.",
23+
source.getNode(), "user-provided value"

0 commit comments

Comments
 (0)