Skip to content

Commit c88a0cc

Browse files
committed
Python: Move experimental TimingAttackAgainstHash to new dataflow API
1 parent a779547 commit c88a0cc

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,24 @@ import python
1616
import semmle.python.dataflow.new.DataFlow
1717
import semmle.python.dataflow.new.TaintTracking
1818
import experimental.semmle.python.security.TimingAttack
19-
import DataFlow::PathGraph
2019

2120
/**
2221
* A configuration that tracks data flow from cryptographic operations
2322
* to Equality test.
2423
*/
25-
class TimingAttackAgainsthash extends TaintTracking::Configuration {
26-
TimingAttackAgainsthash() { this = "TimingAttackAgainsthash" }
24+
private module TimingAttackAgainstHashConfig implements DataFlow::ConfigSig {
25+
predicate isSource(DataFlow::Node source) { source instanceof ProduceCryptoCall }
2726

28-
override predicate isSource(DataFlow::Node source) { source instanceof ProduceCryptoCall }
29-
30-
override predicate isSink(DataFlow::Node sink) { sink instanceof NonConstantTimeComparisonSink }
27+
predicate isSink(DataFlow::Node sink) { sink instanceof NonConstantTimeComparisonSink }
3128
}
3229

33-
from TimingAttackAgainsthash config, DataFlow::PathNode source, DataFlow::PathNode sink
30+
module TimingAttackAgainstHashFlow = TaintTracking::Global<TimingAttackAgainstHashConfig>;
31+
32+
import TimingAttackAgainstHashFlow::PathGraph
33+
34+
from TimingAttackAgainstHashFlow::PathNode source, TimingAttackAgainstHashFlow::PathNode sink
3435
where
35-
config.hasFlowPath(source, sink) and
36+
TimingAttackAgainstHashFlow::flowPath(source, sink) and
3637
sink.getNode().(NonConstantTimeComparisonSink).includesUserInput()
3738
select sink.getNode(), source, sink, "Timing attack against $@ validation.",
3839
source.getNode().(ProduceCryptoCall).getResultType(), "message"

0 commit comments

Comments
 (0)