22 * @name Unsafe HMAC Comparison
33 * @description An HMAC is being compared using the equality operator. This may be vulnerable to a cryptographic timing attack
44 * because the equality operation does not occur in constant time."
5-
65 * @kind path-problem
76 * @problem.severity error
87 * @security-severity 6.0
1211 * external/cwe/cwe-208
1312 */
1413
15-
14+ private import codeql.ruby.AST
1615private import codeql.ruby.DataFlow
1716import codeql.ruby.ApiGraphs
1817import ruby
@@ -29,19 +28,17 @@ private class OpenSslHmacSource extends DataFlow::Node {
2928
3029private module UnsafeHmacComparison {
3130 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 }
3532
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+ }
4037 }
4138
4239 import DataFlow:: Global< Config >
4340}
4441
4542from UnsafeHmacComparison:: PathNode source , UnsafeHmacComparison:: PathNode sink
4643where 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