Skip to content

Commit 12dcabe

Browse files
committed
Add ExecTaintedLocal
1 parent 16cc1f2 commit 12dcabe

2 files changed

Lines changed: 29 additions & 22 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/** Provides a taint-tracking configuration to reason about use of externally controlled strings to make command line commands. */
2+
3+
import java
4+
private import semmle.code.java.dataflow.FlowSources
5+
private import semmle.code.java.security.ExternalProcess
6+
private import semmle.code.java.security.CommandArguments
7+
8+
/** A taint-tracking configuration to reason about use of externally controlled strings to make command line commands. */
9+
module LocalUserInputToArgumentToExecFlowConfig implements DataFlow::ConfigSig {
10+
predicate isSource(DataFlow::Node src) { src instanceof LocalUserInput }
11+
12+
predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof ArgumentToExec }
13+
14+
predicate isBarrier(DataFlow::Node node) {
15+
node.getType() instanceof PrimitiveType
16+
or
17+
node.getType() instanceof BoxedType
18+
or
19+
isSafeCommandArgument(node.asExpr())
20+
}
21+
}
22+
23+
/**
24+
* Taint-tracking flow for use of externally controlled strings to make command line commands.
25+
*/
26+
module LocalUserInputToArgumentToExecFlow =
27+
TaintTracking::Global<LocalUserInputToArgumentToExecFlowConfig>;

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

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,8 @@
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 java
16+
import semmle.code.java.security.ExecTaintedLocalQuery
3717
import LocalUserInputToArgumentToExecFlow::PathGraph
3818

3919
from

0 commit comments

Comments
 (0)