-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathExecTaintedLocal.ql
More file actions
27 lines (24 loc) · 1.23 KB
/
ExecTaintedLocal.ql
File metadata and controls
27 lines (24 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* @name Local-user-controlled command line
* @description Using externally controlled strings in a command line is vulnerable to malicious
* changes in the strings.
* @kind problem
* @problem.severity recommendation
* @precision medium
* @id java/command-line-injection-local
* @tags security
* external/cwe/cwe-078
* external/cwe/cwe-088
*/
import semmle.code.java.Expr
import semmle.code.java.dataflow.FlowSources
import semmle.code.java.security.ExternalProcess
class LocalUserInputToArgumentToExecFlowConfig extends TaintTracking::Configuration {
LocalUserInputToArgumentToExecFlowConfig() { this = "LocalUserInputToArgumentToExecFlowConfig" }
override predicate isSource(DataFlow::Node src) { src instanceof LocalUserInput }
override predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof ArgumentToExec }
override predicate isSanitizer(DataFlow::Node node) { node.getType() instanceof PrimitiveType or node.getType() instanceof BoxedType }
}
from StringArgumentToExec execArg, LocalUserInput origin, LocalUserInputToArgumentToExecFlowConfig conf
where conf.hasFlow(origin, DataFlow::exprNode(execArg))
select execArg, "$@ flows to here and is used in a command.", origin, "User-provided value"