Skip to content

Commit bd34b6c

Browse files
committed
Crypto: Removing JCA model of random, need to reassess this as this impacts the insecure IV/Nonce query. Updated name of the Insecure nonce query to be InsecureIVorNonce
1 parent 143be8c commit bd34b6c

File tree

3 files changed

+19
-37
lines changed

3 files changed

+19
-37
lines changed

java/ql/lib/experimental/quantum/JCA.qll

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,21 +1095,6 @@ module JCAModel {
10951095
}
10961096
}
10971097

1098-
/**
1099-
* An instance of `java.security.SecureRandom.nextBytes(byte[])` call.
1100-
* This is already generally modeled for Java in CodeQL, but
1101-
* we model it again as part of the crypto API model to have a cohesive model.
1102-
*/
1103-
class JavaSecuritySecureRandom extends Crypto::RandomNumberGenerationInstance instanceof Call {
1104-
JavaSecuritySecureRandom() {
1105-
this.getCallee().hasQualifiedName("java.security", "SecureRandom", "nextBytes")
1106-
}
1107-
1108-
override Crypto::DataFlowNode getOutputNode() { result.asExpr() = this.(Call).getArgument(0) }
1109-
1110-
override string getGeneratorName() { result = this.(Call).getCallee().getName() }
1111-
}
1112-
11131098
class KeyGeneratorGenerateCall extends Crypto::KeyGenerationOperationInstance instanceof MethodCall
11141099
{
11151100
Crypto::KeyArtifactType type;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @name Insecure nonce (static value or weak random source)
3+
* @id java/quantum/insecure-iv-or-nonce
4+
* @description A nonce is generated from a source that is not secure. This can lead to
5+
* vulnerabilities such as replay attacks or key recovery.
6+
* @kind problem
7+
* @problem.severity error
8+
* @precision high
9+
* @tags quantum
10+
* experimental
11+
*/
12+
13+
import experimental.quantum.Language
14+
15+
from Crypto::NonceArtifactNode nonce, Crypto::NodeBase src
16+
where
17+
nonce.getSourceNode() = src and
18+
not src.asElement() instanceof SecureRandomnessInstance
19+
select nonce, "Nonce or IV uses insecure nonce source $@", src, src.toString()

java/ql/src/experimental/quantum/Analysis/InsecureNonceSource.ql

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)