Skip to content

Commit 4199859

Browse files
authored
Merge pull request #20079 from d10c/d10c/diff-informed-phase-3-python
Python: Diff-informed queries: phase 3 (non-trivial locations)
2 parents b19d1e0 + 20030d5 commit 4199859

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

python/ql/src/experimental/Security/CWE-208/TimingAttackAgainstHash/PossibleTimingAttackAgainstHash.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ private module PossibleTimingAttackAgainstHashConfig implements DataFlow::Config
2626
predicate isSource(DataFlow::Node source) { source instanceof ProduceCryptoCall }
2727

2828
predicate isSink(DataFlow::Node sink) { sink instanceof NonConstantTimeComparisonSink }
29+
30+
predicate observeDiffInformedIncrementalMode() { any() }
2931
}
3032

3133
module PossibleTimingAttackAgainstHashFlow =
@@ -38,4 +40,4 @@ from
3840
PossibleTimingAttackAgainstHashFlow::PathNode sink
3941
where PossibleTimingAttackAgainstHashFlow::flowPath(source, sink)
4042
select sink.getNode(), source, sink, "Possible Timing attack against $@ validation.",
41-
source.getNode().(ProduceCryptoCall).getResultType(), "message"
43+
source.getNode(), source.getNode().(ProduceCryptoCall).getResultType() + " message"

python/ql/src/experimental/Security/CWE-208/TimingAttackAgainstHash/TimingAttackAgainstHash.ql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ private module TimingAttackAgainstHashConfig implements DataFlow::ConfigSig {
2525
predicate isSource(DataFlow::Node source) { source instanceof ProduceCryptoCall }
2626

2727
predicate isSink(DataFlow::Node sink) { sink instanceof NonConstantTimeComparisonSink }
28+
29+
predicate observeDiffInformedIncrementalMode() { any() }
2830
}
2931

3032
module TimingAttackAgainstHashFlow = TaintTracking::Global<TimingAttackAgainstHashConfig>;
@@ -35,5 +37,5 @@ from TimingAttackAgainstHashFlow::PathNode source, TimingAttackAgainstHashFlow::
3537
where
3638
TimingAttackAgainstHashFlow::flowPath(source, sink) and
3739
sink.getNode().(NonConstantTimeComparisonSink).includesUserInput()
38-
select sink.getNode(), source, sink, "Timing attack against $@ validation.",
39-
source.getNode().(ProduceCryptoCall).getResultType(), "message"
40+
select sink.getNode(), source, sink, "Timing attack against $@ validation.", source.getNode(),
41+
source.getNode().(ProduceCryptoCall).getResultType() + " message"

python/ql/test/experimental/query-tests/Security/CWE-208/TimingAttackAgainstHash/PossibleTimingAttackAgainstHash.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ nodes
1010
| TimingAttackAgainstHash.py:37:19:37:48 | ControlFlowNode for sign() | semmle.label | ControlFlowNode for sign() |
1111
subpaths
1212
#select
13-
| TimingAttackAgainstHash.py:27:24:27:32 | ControlFlowNode for signature | TimingAttackAgainstHash.py:26:17:26:41 | ControlFlowNode for Attribute() | TimingAttackAgainstHash.py:27:24:27:32 | ControlFlowNode for signature | Possible Timing attack against $@ validation. | signature | message |
14-
| TimingAttackAgainstHash.py:37:19:37:48 | ControlFlowNode for sign() | TimingAttackAgainstHash.py:30:12:30:47 | ControlFlowNode for Attribute() | TimingAttackAgainstHash.py:37:19:37:48 | ControlFlowNode for sign() | Possible Timing attack against $@ validation. | MAC | message |
13+
| TimingAttackAgainstHash.py:27:24:27:32 | ControlFlowNode for signature | TimingAttackAgainstHash.py:26:17:26:41 | ControlFlowNode for Attribute() | TimingAttackAgainstHash.py:27:24:27:32 | ControlFlowNode for signature | Possible Timing attack against $@ validation. | TimingAttackAgainstHash.py:26:17:26:41 | ControlFlowNode for Attribute() | signature message |
14+
| TimingAttackAgainstHash.py:37:19:37:48 | ControlFlowNode for sign() | TimingAttackAgainstHash.py:30:12:30:47 | ControlFlowNode for Attribute() | TimingAttackAgainstHash.py:37:19:37:48 | ControlFlowNode for sign() | Possible Timing attack against $@ validation. | TimingAttackAgainstHash.py:30:12:30:47 | ControlFlowNode for Attribute() | MAC message |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
edges
2+
| TimingAttackAgainstHash.py:26:5:26:13 | ControlFlowNode for signature | TimingAttackAgainstHash.py:27:24:27:32 | ControlFlowNode for signature | provenance | |
3+
| TimingAttackAgainstHash.py:26:17:26:41 | ControlFlowNode for Attribute() | TimingAttackAgainstHash.py:26:5:26:13 | ControlFlowNode for signature | provenance | |
4+
| TimingAttackAgainstHash.py:30:12:30:47 | ControlFlowNode for Attribute() | TimingAttackAgainstHash.py:37:19:37:48 | ControlFlowNode for sign() | provenance | |
5+
nodes
6+
| TimingAttackAgainstHash.py:26:5:26:13 | ControlFlowNode for signature | semmle.label | ControlFlowNode for signature |
7+
| TimingAttackAgainstHash.py:26:17:26:41 | ControlFlowNode for Attribute() | semmle.label | ControlFlowNode for Attribute() |
8+
| TimingAttackAgainstHash.py:27:24:27:32 | ControlFlowNode for signature | semmle.label | ControlFlowNode for signature |
9+
| TimingAttackAgainstHash.py:30:12:30:47 | ControlFlowNode for Attribute() | semmle.label | ControlFlowNode for Attribute() |
10+
| TimingAttackAgainstHash.py:37:19:37:48 | ControlFlowNode for sign() | semmle.label | ControlFlowNode for sign() |
11+
subpaths
12+
#select
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
experimental/Security/CWE-208/TimingAttackAgainstHash/TimingAttackAgainstHash.ql

0 commit comments

Comments
 (0)