2
2
* @name Unsafe HMAC Comparison
3
3
* @description An HMAC is being compared using the equality operator. This may be vulnerable to a cryptographic timing attack
4
4
* because the equality operation does not occur in constant time."
5
-
6
5
* @kind path-problem
7
6
* @problem.severity error
8
7
* @security-severity 6.0
12
11
* external/cwe/cwe-208
13
12
*/
14
13
15
-
14
+ private import codeql.ruby.AST
16
15
private import codeql.ruby.DataFlow
17
16
import codeql.ruby.ApiGraphs
18
17
import ruby
@@ -29,19 +28,17 @@ private class OpenSslHmacSource extends DataFlow::Node {
29
28
30
29
private module UnsafeHmacComparison {
31
30
private module Config implements DataFlow:: ConfigSig {
32
- predicate isSource ( DataFlow:: Node source ) {
33
- source instanceof OpenSslHmacSource
34
- }
31
+ predicate isSource ( DataFlow:: Node source ) { source instanceof OpenSslHmacSource }
35
32
36
- // Holds if a given sink is an Equality Operation (== or !=)
37
- predicate isSink ( DataFlow:: Node sink ) {
38
- any ( EqualityOperation eqOp ) .getAnOperand ( ) = sink .asExpr ( ) .getExpr ( )
39
- }
33
+ // Holds if a given sink is an Equality Operation (== or !=)
34
+ predicate isSink ( DataFlow:: Node sink ) {
35
+ any ( EqualityOperation eqOp ) .getAnOperand ( ) = sink .asExpr ( ) .getExpr ( )
36
+ }
40
37
}
41
38
42
39
import DataFlow:: Global< Config >
43
40
}
44
41
45
42
from UnsafeHmacComparison:: PathNode source , UnsafeHmacComparison:: PathNode sink
46
43
where UnsafeHmacComparison:: flowPath ( source , sink )
47
- select sink .getNode ( ) , source , sink , "This comparison is potentially vulnerable to a timing attack."
44
+ select sink .getNode ( ) , source , sink , "This comparison is potentially vulnerable to a timing attack."
0 commit comments