11/**
2- * @name Using a not -constant time algorithm for comparison results of a cryptographic operation
2+ * @name Using a non -constant time algorithm for comparing results of a cryptographic operation
33 * @description When comparing results of a cryptographic operation, a constant time algorithm should be used.
44 * Otherwise, an attacker may be able to implement a timing attack.
55 * A successful attack may result in leaking secrets or authentication bypass.
66 * @kind path-problem
77 * @problem.severity error
88 * @precision high
9- * @id java/not -constant-time-crypto-comparison
9+ * @id java/non -constant-time-crypto-comparison
1010 * @tags security
11+ * external/cwe/cwe-385
1112 * external/cwe/cwe-208
1213 */
1314
@@ -16,11 +17,11 @@ import semmle.code.java.dataflow.TaintTracking
1617import DataFlow:: PathGraph
1718
1819/**
19- * A method that returns a result of a cryptographic operation
20+ * A method that returns the result of a cryptographic operation
2021 * such as encryption, decryption, signing, etc.
2122 */
22- private class ReturnCryptoOperatinoResultMethod extends Method {
23- ReturnCryptoOperatinoResultMethod ( ) {
23+ private class ReturnCryptoOperationResultMethod extends Method {
24+ ReturnCryptoOperationResultMethod ( ) {
2425 getDeclaringType ( ) .hasQualifiedName ( "javax.crypto" , [ "Mac" , "Cipher" ] ) and
2526 hasName ( "doFinal" )
2627 or
@@ -30,14 +31,14 @@ private class ReturnCryptoOperatinoResultMethod extends Method {
3031}
3132
3233/**
33- * A configuration that tracks data flows from cryptographic operations
34- * to methods that compare data using a not -constant time algorithm.
34+ * A configuration that tracks data flow from cryptographic operations
35+ * to methods that compare data using a non -constant time algorithm.
3536 */
36- private class NotConstantTimeCryptoComparisonConfig extends TaintTracking:: Configuration {
37- NotConstantTimeCryptoComparisonConfig ( ) { this = "NotConstantTimeCryptoComparisonConfig " }
37+ private class NonConstantTimeCryptoComparisonConfig extends TaintTracking:: Configuration {
38+ NonConstantTimeCryptoComparisonConfig ( ) { this = "NonConstantTimeCryptoComparisonConfig " }
3839
3940 override predicate isSource ( DataFlow:: Node source ) {
40- exists ( MethodAccess ma | ma .getMethod ( ) instanceof ReturnCryptoOperatinoResultMethod |
41+ exists ( MethodAccess ma | ma .getMethod ( ) instanceof ReturnCryptoOperationResultMethod |
4142 ma = source .asExpr ( )
4243 )
4344 }
@@ -59,7 +60,7 @@ private class NotConstantTimeCryptoComparisonConfig extends TaintTracking::Confi
5960 }
6061}
6162
62- from DataFlow:: PathNode source , DataFlow:: PathNode sink , NotConstantTimeCryptoComparisonConfig conf
63+ from DataFlow:: PathNode source , DataFlow:: PathNode sink , NonConstantTimeCryptoComparisonConfig conf
6364where conf .hasFlowPath ( source , sink )
6465select sink .getNode ( ) , source , sink ,
65- "Using a not -constant time algorithm for comparison results of a cryptographic operation."
66+ "Using a non -constant time algorithm for comparing results of a cryptographic operation."
0 commit comments