1
1
/**
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
3
3
* @description When comparing results of a cryptographic operation, a constant time algorithm should be used.
4
4
* Otherwise, an attacker may be able to implement a timing attack.
5
5
* A successful attack may result in leaking secrets or authentication bypass.
6
6
* @kind path-problem
7
7
* @problem.severity error
8
8
* @precision high
9
- * @id java/not -constant-time-crypto-comparison
9
+ * @id java/non -constant-time-crypto-comparison
10
10
* @tags security
11
+ * external/cwe/cwe-385
11
12
* external/cwe/cwe-208
12
13
*/
13
14
@@ -16,11 +17,11 @@ import semmle.code.java.dataflow.TaintTracking
16
17
import DataFlow:: PathGraph
17
18
18
19
/**
19
- * A method that returns a result of a cryptographic operation
20
+ * A method that returns the result of a cryptographic operation
20
21
* such as encryption, decryption, signing, etc.
21
22
*/
22
- private class ReturnCryptoOperatinoResultMethod extends Method {
23
- ReturnCryptoOperatinoResultMethod ( ) {
23
+ private class ReturnCryptoOperationResultMethod extends Method {
24
+ ReturnCryptoOperationResultMethod ( ) {
24
25
getDeclaringType ( ) .hasQualifiedName ( "javax.crypto" , [ "Mac" , "Cipher" ] ) and
25
26
hasName ( "doFinal" )
26
27
or
@@ -30,14 +31,14 @@ private class ReturnCryptoOperatinoResultMethod extends Method {
30
31
}
31
32
32
33
/**
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.
35
36
*/
36
- private class NotConstantTimeCryptoComparisonConfig extends TaintTracking:: Configuration {
37
- NotConstantTimeCryptoComparisonConfig ( ) { this = "NotConstantTimeCryptoComparisonConfig " }
37
+ private class NonConstantTimeCryptoComparisonConfig extends TaintTracking:: Configuration {
38
+ NonConstantTimeCryptoComparisonConfig ( ) { this = "NonConstantTimeCryptoComparisonConfig " }
38
39
39
40
override predicate isSource ( DataFlow:: Node source ) {
40
- exists ( MethodAccess ma | ma .getMethod ( ) instanceof ReturnCryptoOperatinoResultMethod |
41
+ exists ( MethodAccess ma | ma .getMethod ( ) instanceof ReturnCryptoOperationResultMethod |
41
42
ma = source .asExpr ( )
42
43
)
43
44
}
@@ -59,7 +60,7 @@ private class NotConstantTimeCryptoComparisonConfig extends TaintTracking::Confi
59
60
}
60
61
}
61
62
62
- from DataFlow:: PathNode source , DataFlow:: PathNode sink , NotConstantTimeCryptoComparisonConfig conf
63
+ from DataFlow:: PathNode source , DataFlow:: PathNode sink , NonConstantTimeCryptoComparisonConfig conf
63
64
where conf .hasFlowPath ( source , sink )
64
65
select 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