Skip to content

Commit 3bf2705

Browse files
committed
Python: Move experimental TimingAttackAgainstHeaderValue to new dataflow API
1 parent c88a0cc commit 3bf2705

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,26 @@ import python
1515
import semmle.python.dataflow.new.DataFlow
1616
import semmle.python.dataflow.new.TaintTracking
1717
import experimental.semmle.python.security.TimingAttack
18-
import DataFlow::PathGraph
1918

2019
/**
2120
* A configuration tracing flow from a client Secret obtained by an HTTP header to a unsafe Comparison.
2221
*/
23-
class ClientSuppliedSecretConfig extends TaintTracking::Configuration {
24-
ClientSuppliedSecretConfig() { this = "ClientSuppliedSecretConfig" }
22+
private module TimingAttackAgainstHeaderValueConfig implements DataFlow::ConfigSig {
23+
predicate isSource(DataFlow::Node source) { source instanceof ClientSuppliedSecret }
2524

26-
override predicate isSource(DataFlow::Node source) { source instanceof ClientSuppliedSecret }
27-
28-
override predicate isSink(DataFlow::Node sink) { sink instanceof CompareSink }
25+
predicate isSink(DataFlow::Node sink) { sink instanceof CompareSink }
2926
}
3027

31-
from ClientSuppliedSecretConfig config, DataFlow::PathNode source, DataFlow::PathNode sink
32-
where config.hasFlowPath(source, sink) and not sink.getNode().(CompareSink).flowtolen()
28+
module TimingAttackAgainstHeaderValueFlow =
29+
TaintTracking::Global<TimingAttackAgainstHeaderValueConfig>;
30+
31+
import TimingAttackAgainstHeaderValueFlow::PathGraph
32+
33+
from
34+
TimingAttackAgainstHeaderValueFlow::PathNode source,
35+
TimingAttackAgainstHeaderValueFlow::PathNode sink
36+
where
37+
TimingAttackAgainstHeaderValueFlow::flowPath(source, sink) and
38+
not sink.getNode().(CompareSink).flowtolen()
3339
select sink.getNode(), source, sink, "Timing attack against $@ validation.", source.getNode(),
3440
"client-supplied token"

0 commit comments

Comments
 (0)