Skip to content

Commit 85a4dd0

Browse files
committed
Java: Deprecate the local content of CommandLineQuery and remove the exec tainted local query variant.
1 parent 072f190 commit 85a4dd0

File tree

10 files changed

+31
-53
lines changed

10 files changed

+31
-53
lines changed

java/ql/automodel/src/AutomodelAlertSinkUtil.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,7 @@ predicate sinkModelTallyPerQuery(string queryName, int alertCount, SinkModel sin
159159
SinkTallier<RequestForgeryConfig>::getSinkModelCount(alertCount, sinkModel)
160160
or
161161
queryName = "java/command-line-injection" and
162-
exists(int c1, int c2 |
163-
SinkTallier<RemoteUserInputToArgumentToExecFlowConfig>::getSinkModelCount(c1, sinkModel) and
164-
SinkTallier<LocalUserInputToArgumentToExecFlowConfig>::getSinkModelCount(c2, sinkModel) and
165-
alertCount = c1 + c2
166-
)
162+
SinkTallier<InputToArgumentToExecFlowConfig>::getSinkModelCount(alertCount, sinkModel)
167163
or
168164
queryName = "java/concatenated-sql-query" and
169165
SinkTallier<UncontrolledStringBuilderSourceFlowConfig>::getSinkModelCount(alertCount, sinkModel)

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ private class DefaultCommandInjectionSanitizer extends CommandInjectionSanitizer
4848
/**
4949
* A taint-tracking configuration for unvalidated user input that is used to run an external process.
5050
*/
51-
module RemoteUserInputToArgumentToExecFlowConfig implements DataFlow::ConfigSig {
51+
module InputToArgumentToExecFlowConfig implements DataFlow::ConfigSig {
5252
predicate isSource(DataFlow::Node src) { src instanceof ThreatModelFlowSource }
5353

5454
predicate isSink(DataFlow::Node sink) { sink instanceof CommandInjectionSink }
@@ -61,15 +61,24 @@ module RemoteUserInputToArgumentToExecFlowConfig implements DataFlow::ConfigSig
6161
}
6262

6363
/**
64-
* Taint-tracking flow for unvalidated user input that is used to run an external process.
64+
* DEPRECATED: Use `InputToArgumentToExecFlowConfig` instead.
6565
*/
66-
module RemoteUserInputToArgumentToExecFlow =
67-
TaintTracking::Global<RemoteUserInputToArgumentToExecFlowConfig>;
66+
deprecated module RemoteUserInputToArgumentToExecFlowConfig = InputToArgumentToExecFlowConfig;
67+
68+
/**
69+
* Taint-tracking flow for unvalidated input that is used to run an external process.
70+
*/
71+
module InputToArgumentToExecFlow = TaintTracking::Global<InputToArgumentToExecFlowConfig>;
72+
73+
/**
74+
* DEPRECATED: Use `InputToArgumentToExecFlow` instead.
75+
*/
76+
deprecated module RemoteUserInputToArgumentToExecFlow = InputToArgumentToExecFlow;
6877

6978
/**
7079
* A taint-tracking configuration for unvalidated local user input that is used to run an external process.
7180
*/
72-
module LocalUserInputToArgumentToExecFlowConfig implements DataFlow::ConfigSig {
81+
deprecated module LocalUserInputToArgumentToExecFlowConfig implements DataFlow::ConfigSig {
7382
predicate isSource(DataFlow::Node src) { src instanceof LocalUserInput }
7483

7584
predicate isSink(DataFlow::Node sink) { sink instanceof CommandInjectionSink }
@@ -82,9 +91,11 @@ module LocalUserInputToArgumentToExecFlowConfig implements DataFlow::ConfigSig {
8291
}
8392

8493
/**
94+
* DEPRECATED: Use `InputToArgumentToExecFlow` instead and configure threat model sources to include `local`.
95+
*
8596
* Taint-tracking flow for unvalidated local user input that is used to run an external process.
8697
*/
87-
module LocalUserInputToArgumentToExecFlow =
98+
deprecated module LocalUserInputToArgumentToExecFlow =
8899
TaintTracking::Global<LocalUserInputToArgumentToExecFlowConfig>;
89100

90101
/**
@@ -93,10 +104,9 @@ module LocalUserInputToArgumentToExecFlow =
93104
* reporting overlapping results.
94105
*/
95106
predicate execIsTainted(
96-
RemoteUserInputToArgumentToExecFlow::PathNode source,
97-
RemoteUserInputToArgumentToExecFlow::PathNode sink, Expr execArg
107+
InputToArgumentToExecFlow::PathNode source, InputToArgumentToExecFlow::PathNode sink, Expr execArg
98108
) {
99-
RemoteUserInputToArgumentToExecFlow::flowPath(source, sink) and
109+
InputToArgumentToExecFlow::flowPath(source, sink) and
100110
argumentToExec(execArg, sink.getNode())
101111
}
102112

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@
1414

1515
import java
1616
import semmle.code.java.security.CommandLineQuery
17-
import RemoteUserInputToArgumentToExecFlow::PathGraph
17+
import InputToArgumentToExecFlow::PathGraph
1818

1919
from
20-
RemoteUserInputToArgumentToExecFlow::PathNode source,
21-
RemoteUserInputToArgumentToExecFlow::PathNode sink, Expr execArg
20+
InputToArgumentToExecFlow::PathNode source, InputToArgumentToExecFlow::PathNode sink, Expr execArg
2221
where execIsTainted(source, sink, execArg)
2322
select execArg, source, sink, "This command line depends on a $@.", source.getNode(),
2423
"user-provided value"

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

Lines changed: 0 additions & 5 deletions
This file was deleted.

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

Lines changed: 0 additions & 27 deletions
This file was deleted.

java/ql/src/experimental/Security/CWE/CWE-078/ExecTainted.ql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import java
1616
import semmle.code.java.security.CommandLineQuery
17-
import RemoteUserInputToArgumentToExecFlow::PathGraph
17+
import InputToArgumentToExecFlow::PathGraph
1818
private import semmle.code.java.dataflow.ExternalFlow
1919

2020
private class ActivateModels extends ActiveExperimentalModels {
@@ -23,8 +23,7 @@ private class ActivateModels extends ActiveExperimentalModels {
2323

2424
// This is a clone of query `java/command-line-injection` that also includes experimental sinks.
2525
from
26-
RemoteUserInputToArgumentToExecFlow::PathNode source,
27-
RemoteUserInputToArgumentToExecFlow::PathNode sink, Expr execArg
26+
InputToArgumentToExecFlow::PathNode source, InputToArgumentToExecFlow::PathNode sink, Expr execArg
2827
where execIsTainted(source, sink, execArg)
2928
select execArg, source, sink, "This command line depends on a $@.", source.getNode(),
3029
"user-provided value"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
extensions:
2+
- addsTo:
3+
pack: codeql/threat-models
4+
extensible: threatModelConfiguration
5+
data:
6+
- ["local", true, 0]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Security/CWE/CWE-078/ExecTainted.ql

java/ql/test/query-tests/security/CWE-078/ExecTaintedLocal.qlref

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)