@@ -16,23 +16,24 @@ import python
16
16
import semmle.python.dataflow.new.DataFlow
17
17
import semmle.python.dataflow.new.TaintTracking
18
18
import experimental.semmle.python.security.TimingAttack
19
- import DataFlow:: PathGraph
20
19
21
20
/**
22
21
* A configuration that tracks data flow from cryptographic operations
23
22
* to Equality test.
24
23
*/
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 }
27
26
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 }
31
28
}
32
29
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
34
35
where
35
- config . hasFlowPath ( source , sink ) and
36
+ TimingAttackAgainstHashFlow :: flowPath ( source , sink ) and
36
37
sink .getNode ( ) .( NonConstantTimeComparisonSink ) .includesUserInput ( )
37
38
select sink .getNode ( ) , source , sink , "Timing attack against $@ validation." ,
38
39
source .getNode ( ) .( ProduceCryptoCall ) .getResultType ( ) , "message"
0 commit comments