Java: Improve the ExecTainted query

This commit is contained in:
Joe
2020-09-17 15:01:04 +01:00
parent 5079deb92a
commit 6bfc0afaeb
3 changed files with 221 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
import semmle.code.java.dataflow.FlowSources
import semmle.code.java.security.ExternalProcess
import semmle.code.java.security.CommandArguments
private class RemoteUserInputToArgumentToExecFlowConfig extends TaintTracking::Configuration {
RemoteUserInputToArgumentToExecFlowConfig() {
@@ -11,7 +12,11 @@ private class RemoteUserInputToArgumentToExecFlowConfig extends TaintTracking::C
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
node.getType() instanceof PrimitiveType
or
node.getType() instanceof BoxedType
or
isSafeCommandArgument(node.asExpr())
}
}

View File

@@ -17,7 +17,7 @@ import semmle.code.java.security.ExternalProcess
import ExecCommon
import DataFlow::PathGraph
from DataFlow::PathNode source, DataFlow::PathNode sink, StringArgumentToExec execArg
from DataFlow::PathNode source, DataFlow::PathNode sink, ArgumentToExec execArg
where execTainted(source, sink, execArg)
select execArg, source, sink, "$@ flows to here and is used in a command.", source.getNode(),
"User-provided value"