Skip to content

Commit 072f190

Browse files
committed
Java: Deprecate the content of ArithmeticTaintedLocalQuery and remove the arithmetic tainted local query variant.
1 parent 93988e5 commit 072f190

File tree

9 files changed

+50
-61
lines changed

9 files changed

+50
-61
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ private import semmle.code.java.dataflow.FlowSources
55
private import semmle.code.java.security.ArithmeticCommon
66

77
/**
8+
* DEPRECATED: Use `ArithmeticOverflowConfig` instead.
9+
*
810
* A taint-tracking configuration to reason about arithmetic overflow using local-user-controlled data.
911
*/
10-
module ArithmeticTaintedLocalOverflowConfig implements DataFlow::ConfigSig {
12+
deprecated module ArithmeticTaintedLocalOverflowConfig implements DataFlow::ConfigSig {
1113
predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput }
1214

1315
predicate isSink(DataFlow::Node sink) { overflowSink(_, sink.asExpr()) }
@@ -18,15 +20,17 @@ module ArithmeticTaintedLocalOverflowConfig implements DataFlow::ConfigSig {
1820
}
1921

2022
/**
23+
* DEPRECATED: Use `ArithmeticOverflow` instead and configure threat model sources to include `local`.
24+
*
2125
* Taint-tracking flow for arithmetic overflow using local-user-controlled data.
2226
*/
23-
module ArithmeticTaintedLocalOverflowFlow =
27+
deprecated module ArithmeticTaintedLocalOverflowFlow =
2428
TaintTracking::Global<ArithmeticTaintedLocalOverflowConfig>;
2529

2630
/**
2731
* A taint-tracking configuration to reason about arithmetic underflow using local-user-controlled data.
2832
*/
29-
module ArithmeticTaintedLocalUnderflowConfig implements DataFlow::ConfigSig {
33+
deprecated module ArithmeticTaintedLocalUnderflowConfig implements DataFlow::ConfigSig {
3034
predicate isSource(DataFlow::Node source) { source instanceof LocalUserInput }
3135

3236
predicate isSink(DataFlow::Node sink) { underflowSink(_, sink.asExpr()) }
@@ -37,7 +41,9 @@ module ArithmeticTaintedLocalUnderflowConfig implements DataFlow::ConfigSig {
3741
}
3842

3943
/**
44+
* DEPRECATED: Use `ArithmeticUnderflow` instead and configure threat model sources to include `local`.
45+
*
4046
* Taint-tracking flow for arithmetic underflow using local-user-controlled data.
4147
*/
42-
module ArithmeticTaintedLocalUnderflowFlow =
48+
deprecated module ArithmeticTaintedLocalUnderflowFlow =
4349
TaintTracking::Global<ArithmeticTaintedLocalUnderflowConfig>;
Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
/** Provides taint-tracking configurations to reason about arithmetic with unvalidated user input. */
1+
/** Provides taint-tracking configurations to reason about arithmetic with unvalidated input. */
22

33
import java
44
private import semmle.code.java.dataflow.FlowSources
55
private import semmle.code.java.security.ArithmeticCommon
66

7-
/** A taint-tracking configuration to reason about overflow from unvalidated user input. */
8-
module RemoteUserInputOverflowConfig implements DataFlow::ConfigSig {
7+
/** A taint-tracking configuration to reason about overflow from unvalidated input. */
8+
module ArithmeticOverflowConfig implements DataFlow::ConfigSig {
99
predicate isSource(DataFlow::Node source) { source instanceof ThreatModelFlowSource }
1010

1111
predicate isSink(DataFlow::Node sink) { overflowSink(_, sink.asExpr()) }
@@ -15,8 +15,13 @@ module RemoteUserInputOverflowConfig implements DataFlow::ConfigSig {
1515
predicate isBarrierIn(DataFlow::Node node) { isSource(node) }
1616
}
1717

18-
/** A taint-tracking configuration to reason about underflow from unvalidated user input. */
19-
module RemoteUserInputUnderflowConfig implements DataFlow::ConfigSig {
18+
/**
19+
* DEPRECATED: Use `ArithmeticOverflowConfig` instead.
20+
*/
21+
deprecated module RemoteUserInputOverflowConfig = ArithmeticOverflowConfig;
22+
23+
/** A taint-tracking configuration to reason about underflow from unvalidated input. */
24+
module ArithmeticUnderflowConfig implements DataFlow::ConfigSig {
2025
predicate isSource(DataFlow::Node source) { source instanceof ThreatModelFlowSource }
2126

2227
predicate isSink(DataFlow::Node sink) { underflowSink(_, sink.asExpr()) }
@@ -26,8 +31,23 @@ module RemoteUserInputUnderflowConfig implements DataFlow::ConfigSig {
2631
predicate isBarrierIn(DataFlow::Node node) { isSource(node) }
2732
}
2833

29-
/** Taint-tracking flow for overflow from unvalidated user input. */
30-
module RemoteUserInputOverflow = TaintTracking::Global<RemoteUserInputOverflowConfig>;
34+
/**
35+
* DEPRECATED: Use `ArithmeticUnderflowConfig` instead.
36+
*/
37+
deprecated module RemoteUserInputUnderflowConfig = ArithmeticUnderflowConfig;
38+
39+
/** Taint-tracking flow for overflow from unvalidated input. */
40+
module ArithmeticOverflow = TaintTracking::Global<ArithmeticOverflowConfig>;
41+
42+
/**
43+
* DEPRECATED: Use `ArithmeticOverflow` instead.
44+
*/
45+
deprecated module RemoteUserInputOverflow = ArithmeticOverflow;
46+
47+
/** Taint-tracking flow for underflow from unvalidated input. */
48+
module ArithmeticUnderflow = TaintTracking::Global<ArithmeticUnderflowConfig>;
3149

32-
/** Taint-tracking flow for underflow from unvalidated user input. */
33-
module RemoteUserInputUnderflow = TaintTracking::Global<RemoteUserInputUnderflowConfig>;
50+
/**
51+
* DEPRECATED: Use `ArithmeticUnderflow` instead.
52+
*/
53+
deprecated module RemoteUserInputUnderflow = ArithmeticUnderflow;

java/ql/src/Security/CWE/CWE-190/ArithmeticTainted.ql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ import semmle.code.java.security.ArithmeticCommon
1818
import semmle.code.java.security.ArithmeticTaintedQuery
1919

2020
module Flow =
21-
DataFlow::MergePathGraph<RemoteUserInputOverflow::PathNode, RemoteUserInputUnderflow::PathNode,
22-
RemoteUserInputOverflow::PathGraph, RemoteUserInputUnderflow::PathGraph>;
21+
DataFlow::MergePathGraph<ArithmeticOverflow::PathNode, ArithmeticUnderflow::PathNode,
22+
ArithmeticOverflow::PathGraph, ArithmeticUnderflow::PathGraph>;
2323

2424
import Flow::PathGraph
2525

2626
from Flow::PathNode source, Flow::PathNode sink, ArithExpr exp, string effect
2727
where
28-
RemoteUserInputOverflow::flowPath(source.asPathNode1(), sink.asPathNode1()) and
28+
ArithmeticOverflow::flowPath(source.asPathNode1(), sink.asPathNode1()) and
2929
overflowSink(exp, sink.getNode().asExpr()) and
3030
effect = "overflow"
3131
or
32-
RemoteUserInputUnderflow::flowPath(source.asPathNode2(), sink.asPathNode2()) and
32+
ArithmeticUnderflow::flowPath(source.asPathNode2(), sink.asPathNode2()) and
3333
underflowSink(exp, sink.getNode().asExpr()) and
3434
effect = "underflow"
3535
select exp, source, sink,

java/ql/src/Security/CWE/CWE-190/ArithmeticTaintedLocal.qhelp

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

java/ql/src/Security/CWE/CWE-190/ArithmeticTaintedLocal.ql

Lines changed: 0 additions & 38 deletions
This file was deleted.
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-190/ArithmeticTainted.ql

java/ql/test/query-tests/security/CWE-190/semmle/tests/ArithmeticTaintedLocal.qlref

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

0 commit comments

Comments
 (0)