|
11 | 11 | * external/cwe/cwe-078
|
12 | 12 | */
|
13 | 13 |
|
14 |
| - |
15 | 14 | import DataFlow::PathGraph
|
16 | 15 | import CommandInjectionRuntimeExec
|
17 | 16 |
|
18 |
| -class RemoteSource extends Source { RemoteSource() { this instanceof RemoteFlowSource } } |
| 17 | +class RemoteSource extends Source { |
| 18 | + RemoteSource() { this instanceof RemoteFlowSource } |
| 19 | +} |
19 | 20 |
|
20 |
| -from DataFlow::PathNode source, DataFlow::PathNode sink, ExecTaintConfiguration2 conf, MethodAccess call, DataFlow::Node sourceCmd, DataFlow::Node sinkCmd, ExecTaintConfiguration confCmd |
21 |
| -where call.getMethod() instanceof RuntimeExecMethod |
22 |
| -// this is a command-accepting call to exec, e.g. rt.exec(new String[]{"/bin/sh", ...}) |
23 |
| -and ( |
24 |
| - confCmd.hasFlow(sourceCmd, sinkCmd) |
25 |
| - and sinkCmd.asExpr() = call.getArgument(0) |
26 |
| -) |
27 |
| -// it is tainted by untrusted user input |
28 |
| -and ( |
29 |
| - conf.hasFlow(source.getNode(), sink.getNode()) |
30 |
| - and sink.getNode().asExpr() = call.getArgument(0) |
31 |
| -) |
32 |
| -select sink, source, sink, "Call to dangerous java.lang.Runtime.exec() with command '$@' with arg from untrusted input '$@'", |
33 |
| - sourceCmd, sourceCmd.toString(), |
34 |
| - source.getNode(), source.toString() |
| 21 | +from |
| 22 | + DataFlow::PathNode source, DataFlow::PathNode sink, ExecTaintConfiguration2 conf, |
| 23 | + MethodAccess call, DataFlow::Node sourceCmd, DataFlow::Node sinkCmd, |
| 24 | + ExecTaintConfiguration confCmd |
| 25 | +where |
| 26 | + call.getMethod() instanceof RuntimeExecMethod and |
| 27 | + // this is a command-accepting call to exec, e.g. rt.exec(new String[]{"/bin/sh", ...}) |
| 28 | + ( |
| 29 | + confCmd.hasFlow(sourceCmd, sinkCmd) and |
| 30 | + sinkCmd.asExpr() = call.getArgument(0) |
| 31 | + ) and |
| 32 | + // it is tainted by untrusted user input |
| 33 | + ( |
| 34 | + conf.hasFlow(source.getNode(), sink.getNode()) and |
| 35 | + sink.getNode().asExpr() = call.getArgument(0) |
| 36 | + ) |
| 37 | +select sink, source, sink, |
| 38 | + "Call to dangerous java.lang.Runtime.exec() with command '$@' with arg from untrusted input '$@'", |
| 39 | + sourceCmd, sourceCmd.toString(), source.getNode(), source.toString() |
0 commit comments