Crypto: Update InsecureIVorNonce to be a path problem.

This commit is contained in:
REDMOND\brodes
2025-10-13 15:29:57 -04:00
parent bd068c2a69
commit 76128ed8dc
4 changed files with 179 additions and 32 deletions

View File

@@ -93,20 +93,6 @@ private class GenericRemoteDataSource extends Crypto::GenericRemoteDataSource {
override string getAdditionalDescription() { result = this.toString() }
}
// /**
// * A property access value (constant from a file)
// */
// class PropertyConstant extends Crypto::GenericConstantSourceInstance instanceof Literal{
// PropertyConstant() {
// value = this.getPropertyValue() and
// // Since properties pairs are not included in the java/weak-cryptographic-algorithm,
// // the check for values from properties files can be less strict than `InsecureAlgoLiteral`.
// not value.regexpMatch(getSecureAlgorithmRegex())
// }
// override string getStringValue() { result = value }
// }
import semmle.code.java.dataflow.RangeUtils
// TODO: import all frameworks?
import semmle.code.java.frameworks.Properties
private import semmle.code.configfiles.ConfigFiles

View File

@@ -6,7 +6,7 @@
* is any static nonce, or any known insecure source for a nonce/iv if
* the value is used for an encryption operation (decryption operations are ignored
* as the nonce/iv would be provided alongside the ciphertext).
* @kind problem
* @kind path-problem
* @problem.severity error
* @precision high
* @tags quantum
@@ -15,7 +15,42 @@
import experimental.quantum.Language
from Crypto::NonceArtifactNode nonce, Crypto::NodeBase src, Crypto::NodeBase op, string msg
module NonceSrcFlowConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
source = any(Crypto::GenericSourceInstance i).getOutputNode() or
source = any(Crypto::ArtifactInstance artifact).getOutputNode()
}
predicate isSink(DataFlow::Node sink) {
exists(Crypto::NonceArtifactNode nonce | sink.asExpr() = nonce.asElement())
}
predicate isBarrierOut(DataFlow::Node node) {
node = any(Crypto::FlowAwareElement element).getInputNode()
}
predicate isBarrierIn(DataFlow::Node node) {
node = any(Crypto::FlowAwareElement element).getOutputNode()
}
predicate isAdditionalFlowStep(DataFlow::Node node1, DataFlow::Node node2) {
node1.(AdditionalFlowInputStep).getOutput() = node2
or
exists(MethodCall m |
m.getMethod().hasQualifiedName("java.lang", "String", "getBytes") and
node1.asExpr() = m.getQualifier() and
node2.asExpr() = m
)
}
}
module NonceSrcFlow = TaintTracking::Global<NonceSrcFlowConfig>;
import NonceSrcFlow::PathGraph
from
Crypto::NonceArtifactNode nonce, Crypto::NodeBase src, Crypto::NodeBase op, string msg,
NonceSrcFlow::PathNode srcNode, NonceSrcFlow::PathNode sinkNode
where
nonce.getSourceNode() = src and
// NOTE: null nonces should be handled seaparately, often used for default values prior to initialization
@@ -25,7 +60,7 @@ where
(
// Case 1: Any constant nonce/iv is bad, regardless of how it is used
src.asElement() instanceof Crypto::GenericConstantSourceInstance and
op = nonce and // binding op by not using it
op = nonce and // binding op but not using it
msg = "Nonce or IV uses constant source $@"
or
// Case 2: The nonce has a non-random source and there is no known operation for the nonce
@@ -47,5 +82,8 @@ where
op.(Crypto::CipherOperationNode).getKeyOperationSubtype() instanceof Crypto::TWrapMode
) and
msg = "Nonce or IV uses insecure source $@ at encryption operation $@"
)
select nonce, msg, src, src.toString(), op, op.toString()
) and
srcNode.getNode().asExpr() = src.asElement() and
sinkNode.getNode().asExpr() = nonce.asElement() and
NonceSrcFlow::flowPath(srcNode, sinkNode)
select sinkNode, srcNode, sinkNode, msg, src, src.toString(), op, op.toString()

View File

@@ -1,7 +1,130 @@
| InsecureIVorNonceSource.java:20:51:20:56 | Nonce | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:14:21:14:81 | Constant | Constant | InsecureIVorNonceSource.java:20:51:20:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:49:51:49:56 | Nonce | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:42:21:42:21 | Constant | Constant | InsecureIVorNonceSource.java:49:51:49:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:65:51:65:56 | Nonce | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:57:13:57:62 | Constant | Constant | InsecureIVorNonceSource.java:65:51:65:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:65:51:65:56 | Nonce | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:58:13:58:63 | Constant | Constant | InsecureIVorNonceSource.java:65:51:65:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:81:51:81:56 | Nonce | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:73:13:73:73 | Constant | Constant | InsecureIVorNonceSource.java:81:51:81:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:81:51:81:56 | Nonce | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:74:13:74:74 | Constant | Constant | InsecureIVorNonceSource.java:81:51:81:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:206:51:206:56 | Nonce | Nonce or IV uses insecure source $@ at encryption operation $@ | InsecureIVorNonceSource.java:194:26:194:30 | RandomNumberGeneration | RandomNumberGeneration | InsecureIVorNonceSource.java:208:16:208:31 | EncryptOperation | EncryptOperation |
#select
| InsecureIVorNonceSource.java:20:51:20:56 | ivSpec | InsecureIVorNonceSource.java:14:21:14:81 | {...} : byte[] | InsecureIVorNonceSource.java:20:51:20:56 | ivSpec | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:14:21:14:81 | Constant | Constant | InsecureIVorNonceSource.java:20:51:20:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:49:51:49:56 | ivSpec | InsecureIVorNonceSource.java:42:21:42:21 | 1 : Number | InsecureIVorNonceSource.java:49:51:49:56 | ivSpec | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:42:21:42:21 | Constant | Constant | InsecureIVorNonceSource.java:49:51:49:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:65:51:65:56 | ivSpec | InsecureIVorNonceSource.java:57:13:57:62 | {...} : byte[] | InsecureIVorNonceSource.java:65:51:65:56 | ivSpec | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:57:13:57:62 | Constant | Constant | InsecureIVorNonceSource.java:65:51:65:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:65:51:65:56 | ivSpec | InsecureIVorNonceSource.java:58:13:58:63 | {...} : byte[] | InsecureIVorNonceSource.java:65:51:65:56 | ivSpec | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:58:13:58:63 | Constant | Constant | InsecureIVorNonceSource.java:65:51:65:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:81:51:81:56 | ivSpec | InsecureIVorNonceSource.java:73:13:73:73 | {...} : byte[] | InsecureIVorNonceSource.java:81:51:81:56 | ivSpec | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:73:13:73:73 | Constant | Constant | InsecureIVorNonceSource.java:81:51:81:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:81:51:81:56 | ivSpec | InsecureIVorNonceSource.java:74:13:74:74 | {...} : byte[] | InsecureIVorNonceSource.java:81:51:81:56 | ivSpec | Nonce or IV uses constant source $@ | InsecureIVorNonceSource.java:74:13:74:74 | Constant | Constant | InsecureIVorNonceSource.java:81:51:81:56 | Nonce | Nonce |
| InsecureIVorNonceSource.java:206:51:206:56 | ivSpec | InsecureIVorNonceSource.java:194:26:194:30 | bytes : byte[] | InsecureIVorNonceSource.java:206:51:206:56 | ivSpec | Nonce or IV uses insecure source $@ at encryption operation $@ | InsecureIVorNonceSource.java:194:26:194:30 | RandomNumberGeneration | RandomNumberGeneration | InsecureIVorNonceSource.java:208:16:208:31 | EncryptOperation | EncryptOperation |
edges
| InsecureIVorNonceSource.java:14:21:14:81 | {...} : byte[] | InsecureIVorNonceSource.java:16:61:16:62 | iv : byte[] | provenance | |
| InsecureIVorNonceSource.java:16:35:16:63 | new GCMParameterSpec(...) : GCMParameterSpec | InsecureIVorNonceSource.java:20:51:20:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:16:61:16:62 | iv : byte[] | InsecureIVorNonceSource.java:16:35:16:63 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:16:61:16:62 | iv : byte[] | InsecureIVorNonceSource.java:16:35:16:63 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | MaD:4 |
| InsecureIVorNonceSource.java:42:13:42:14 | iv [post update] : byte[] [[]] : Number | InsecureIVorNonceSource.java:45:54:45:55 | iv : byte[] [[]] : Number | provenance | |
| InsecureIVorNonceSource.java:42:21:42:21 | 1 : Number | InsecureIVorNonceSource.java:42:13:42:14 | iv [post update] : byte[] [[]] : Number | provenance | |
| InsecureIVorNonceSource.java:45:34:45:56 | new IvParameterSpec(...) : IvParameterSpec | InsecureIVorNonceSource.java:49:51:49:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:45:54:45:55 | iv : byte[] [[]] : Number | InsecureIVorNonceSource.java:45:34:45:56 | new IvParameterSpec(...) : IvParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:56:30:59:9 | {...} : byte[][] [[]] : byte[] | InsecureIVorNonceSource.java:61:61:61:69 | staticIvs : byte[][] [[]] : byte[] | provenance | |
| InsecureIVorNonceSource.java:57:13:57:62 | {...} : byte[] | InsecureIVorNonceSource.java:56:30:59:9 | {...} : byte[][] [[]] : byte[] | provenance | |
| InsecureIVorNonceSource.java:58:13:58:63 | {...} : byte[] | InsecureIVorNonceSource.java:56:30:59:9 | {...} : byte[][] [[]] : byte[] | provenance | |
| InsecureIVorNonceSource.java:61:35:61:73 | new GCMParameterSpec(...) : GCMParameterSpec | InsecureIVorNonceSource.java:65:51:65:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:61:61:61:69 | staticIvs : byte[][] [[]] : byte[] | InsecureIVorNonceSource.java:61:61:61:72 | ...[...] : byte[] | provenance | |
| InsecureIVorNonceSource.java:61:61:61:72 | ...[...] : byte[] | InsecureIVorNonceSource.java:61:35:61:73 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:61:61:61:72 | ...[...] : byte[] | InsecureIVorNonceSource.java:61:35:61:73 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | MaD:4 |
| InsecureIVorNonceSource.java:72:30:75:9 | {...} : byte[][] [[]] : byte[] | InsecureIVorNonceSource.java:77:61:77:69 | staticIvs : byte[][] [[]] : byte[] | provenance | |
| InsecureIVorNonceSource.java:73:13:73:73 | {...} : byte[] | InsecureIVorNonceSource.java:72:30:75:9 | {...} : byte[][] [[]] : byte[] | provenance | |
| InsecureIVorNonceSource.java:74:13:74:74 | {...} : byte[] | InsecureIVorNonceSource.java:72:30:75:9 | {...} : byte[][] [[]] : byte[] | provenance | |
| InsecureIVorNonceSource.java:77:35:77:73 | new GCMParameterSpec(...) : GCMParameterSpec | InsecureIVorNonceSource.java:81:51:81:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:77:61:77:69 | staticIvs : byte[][] [[]] : byte[] | InsecureIVorNonceSource.java:77:61:77:72 | ...[...] : byte[] | provenance | |
| InsecureIVorNonceSource.java:77:61:77:72 | ...[...] : byte[] | InsecureIVorNonceSource.java:77:35:77:73 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:77:61:77:72 | ...[...] : byte[] | InsecureIVorNonceSource.java:77:35:77:73 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | MaD:4 |
| InsecureIVorNonceSource.java:107:26:107:27 | iv : byte[] | InsecureIVorNonceSource.java:109:61:109:62 | iv : byte[] | provenance | |
| InsecureIVorNonceSource.java:109:35:109:63 | new GCMParameterSpec(...) : GCMParameterSpec | InsecureIVorNonceSource.java:113:51:113:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:109:61:109:62 | iv : byte[] | InsecureIVorNonceSource.java:109:35:109:63 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:109:61:109:62 | iv : byte[] | InsecureIVorNonceSource.java:109:35:109:63 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | MaD:4 |
| InsecureIVorNonceSource.java:123:13:123:14 | iv [post update] : byte[] [[]] : Number | InsecureIVorNonceSource.java:126:61:126:62 | iv : byte[] [[]] : Number | provenance | |
| InsecureIVorNonceSource.java:123:21:123:43 | (...)... : Number | InsecureIVorNonceSource.java:123:13:123:14 | iv [post update] : byte[] [[]] : Number | provenance | |
| InsecureIVorNonceSource.java:123:28:123:43 | nextInt(...) : Number | InsecureIVorNonceSource.java:123:21:123:43 | (...)... : Number | provenance | |
| InsecureIVorNonceSource.java:126:35:126:63 | new GCMParameterSpec(...) : GCMParameterSpec | InsecureIVorNonceSource.java:130:51:130:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:126:61:126:62 | iv : byte[] [[]] : Number | InsecureIVorNonceSource.java:126:35:126:63 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:138:52:138:62 | randomBytes : byte[] | InsecureIVorNonceSource.java:141:26:141:36 | randomBytes : byte[] | provenance | |
| InsecureIVorNonceSource.java:141:26:141:36 | randomBytes : byte[] | InsecureIVorNonceSource.java:141:42:141:43 | iv [post update] : byte[] | provenance | MaD:2 |
| InsecureIVorNonceSource.java:141:42:141:43 | iv [post update] : byte[] | InsecureIVorNonceSource.java:143:61:143:62 | iv : byte[] | provenance | |
| InsecureIVorNonceSource.java:143:35:143:63 | new GCMParameterSpec(...) : GCMParameterSpec | InsecureIVorNonceSource.java:147:51:147:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:143:61:143:62 | iv : byte[] | InsecureIVorNonceSource.java:143:35:143:63 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:143:61:143:62 | iv : byte[] | InsecureIVorNonceSource.java:143:35:143:63 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | MaD:4 |
| InsecureIVorNonceSource.java:155:52:155:62 | randomBytes : byte[] | InsecureIVorNonceSource.java:158:28:158:38 | randomBytes : byte[] | provenance | |
| InsecureIVorNonceSource.java:158:14:158:43 | copyOf(...) : byte[] [[]] : Object | InsecureIVorNonceSource.java:160:61:160:62 | iv : byte[] [[]] : Object | provenance | |
| InsecureIVorNonceSource.java:158:28:158:38 | randomBytes : byte[] | InsecureIVorNonceSource.java:158:14:158:43 | copyOf(...) : byte[] [[]] : Object | provenance | MaD:3 |
| InsecureIVorNonceSource.java:160:35:160:63 | new GCMParameterSpec(...) : GCMParameterSpec | InsecureIVorNonceSource.java:164:51:164:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:160:61:160:62 | iv : byte[] [[]] : Object | InsecureIVorNonceSource.java:160:35:160:63 | new GCMParameterSpec(...) : GCMParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:174:52:174:62 | randomBytes : byte[] | InsecureIVorNonceSource.java:175:16:175:26 | randomBytes : byte[] | provenance | |
| InsecureIVorNonceSource.java:175:16:175:26 | randomBytes : byte[] | InsecureIVorNonceSource.java:180:21:180:32 | generate(...) : byte[] | provenance | |
| InsecureIVorNonceSource.java:180:21:180:32 | generate(...) : byte[] | InsecureIVorNonceSource.java:182:54:182:55 | iv : byte[] | provenance | |
| InsecureIVorNonceSource.java:182:34:182:56 | new IvParameterSpec(...) : IvParameterSpec | InsecureIVorNonceSource.java:186:51:186:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:182:54:182:55 | iv : byte[] | InsecureIVorNonceSource.java:182:34:182:56 | new IvParameterSpec(...) : IvParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:182:54:182:55 | iv : byte[] | InsecureIVorNonceSource.java:182:34:182:56 | new IvParameterSpec(...) : IvParameterSpec | provenance | MaD:5 |
| InsecureIVorNonceSource.java:194:26:194:30 | bytes : byte[] | InsecureIVorNonceSource.java:195:16:195:20 | bytes : byte[] | provenance | |
| InsecureIVorNonceSource.java:195:16:195:20 | bytes : byte[] | InsecureIVorNonceSource.java:200:21:200:51 | generateInsecureRandomBytes(...) : byte[] | provenance | |
| InsecureIVorNonceSource.java:200:21:200:51 | generateInsecureRandomBytes(...) : byte[] | InsecureIVorNonceSource.java:202:54:202:55 | iv : byte[] | provenance | |
| InsecureIVorNonceSource.java:202:34:202:56 | new IvParameterSpec(...) : IvParameterSpec | InsecureIVorNonceSource.java:206:51:206:56 | ivSpec | provenance | Sink:MaD:1 |
| InsecureIVorNonceSource.java:202:54:202:55 | iv : byte[] | InsecureIVorNonceSource.java:202:34:202:56 | new IvParameterSpec(...) : IvParameterSpec | provenance | Config |
| InsecureIVorNonceSource.java:202:54:202:55 | iv : byte[] | InsecureIVorNonceSource.java:202:34:202:56 | new IvParameterSpec(...) : IvParameterSpec | provenance | MaD:5 |
models
| 1 | Sink: javax.crypto; Cipher; true; init; (int,Key,AlgorithmParameterSpec); ; Argument[2]; encryption-iv; manual |
| 2 | Summary: java.lang; System; false; arraycopy; ; ; Argument[0]; Argument[2]; taint; manual |
| 3 | Summary: java.util; Arrays; false; copyOf; ; ; Argument[0].ArrayElement; ReturnValue.ArrayElement; value; manual |
| 4 | Summary: javax.crypto.spec; GCMParameterSpec; true; GCMParameterSpec; ; ; Argument[1]; Argument[this]; taint; manual |
| 5 | Summary: javax.crypto.spec; IvParameterSpec; true; IvParameterSpec; ; ; Argument[0]; Argument[this]; taint; manual |
nodes
| InsecureIVorNonceSource.java:14:21:14:81 | {...} : byte[] | semmle.label | {...} : byte[] |
| InsecureIVorNonceSource.java:16:35:16:63 | new GCMParameterSpec(...) : GCMParameterSpec | semmle.label | new GCMParameterSpec(...) : GCMParameterSpec |
| InsecureIVorNonceSource.java:16:61:16:62 | iv : byte[] | semmle.label | iv : byte[] |
| InsecureIVorNonceSource.java:20:51:20:56 | ivSpec | semmle.label | ivSpec |
| InsecureIVorNonceSource.java:42:13:42:14 | iv [post update] : byte[] [[]] : Number | semmle.label | iv [post update] : byte[] [[]] : Number |
| InsecureIVorNonceSource.java:42:21:42:21 | 1 : Number | semmle.label | 1 : Number |
| InsecureIVorNonceSource.java:45:34:45:56 | new IvParameterSpec(...) : IvParameterSpec | semmle.label | new IvParameterSpec(...) : IvParameterSpec |
| InsecureIVorNonceSource.java:45:54:45:55 | iv : byte[] [[]] : Number | semmle.label | iv : byte[] [[]] : Number |
| InsecureIVorNonceSource.java:49:51:49:56 | ivSpec | semmle.label | ivSpec |
| InsecureIVorNonceSource.java:56:30:59:9 | {...} : byte[][] [[]] : byte[] | semmle.label | {...} : byte[][] [[]] : byte[] |
| InsecureIVorNonceSource.java:57:13:57:62 | {...} : byte[] | semmle.label | {...} : byte[] |
| InsecureIVorNonceSource.java:58:13:58:63 | {...} : byte[] | semmle.label | {...} : byte[] |
| InsecureIVorNonceSource.java:61:35:61:73 | new GCMParameterSpec(...) : GCMParameterSpec | semmle.label | new GCMParameterSpec(...) : GCMParameterSpec |
| InsecureIVorNonceSource.java:61:61:61:69 | staticIvs : byte[][] [[]] : byte[] | semmle.label | staticIvs : byte[][] [[]] : byte[] |
| InsecureIVorNonceSource.java:61:61:61:72 | ...[...] : byte[] | semmle.label | ...[...] : byte[] |
| InsecureIVorNonceSource.java:65:51:65:56 | ivSpec | semmle.label | ivSpec |
| InsecureIVorNonceSource.java:72:30:75:9 | {...} : byte[][] [[]] : byte[] | semmle.label | {...} : byte[][] [[]] : byte[] |
| InsecureIVorNonceSource.java:73:13:73:73 | {...} : byte[] | semmle.label | {...} : byte[] |
| InsecureIVorNonceSource.java:74:13:74:74 | {...} : byte[] | semmle.label | {...} : byte[] |
| InsecureIVorNonceSource.java:77:35:77:73 | new GCMParameterSpec(...) : GCMParameterSpec | semmle.label | new GCMParameterSpec(...) : GCMParameterSpec |
| InsecureIVorNonceSource.java:77:61:77:69 | staticIvs : byte[][] [[]] : byte[] | semmle.label | staticIvs : byte[][] [[]] : byte[] |
| InsecureIVorNonceSource.java:77:61:77:72 | ...[...] : byte[] | semmle.label | ...[...] : byte[] |
| InsecureIVorNonceSource.java:81:51:81:56 | ivSpec | semmle.label | ivSpec |
| InsecureIVorNonceSource.java:107:26:107:27 | iv : byte[] | semmle.label | iv : byte[] |
| InsecureIVorNonceSource.java:109:35:109:63 | new GCMParameterSpec(...) : GCMParameterSpec | semmle.label | new GCMParameterSpec(...) : GCMParameterSpec |
| InsecureIVorNonceSource.java:109:61:109:62 | iv : byte[] | semmle.label | iv : byte[] |
| InsecureIVorNonceSource.java:113:51:113:56 | ivSpec | semmle.label | ivSpec |
| InsecureIVorNonceSource.java:123:13:123:14 | iv [post update] : byte[] [[]] : Number | semmle.label | iv [post update] : byte[] [[]] : Number |
| InsecureIVorNonceSource.java:123:21:123:43 | (...)... : Number | semmle.label | (...)... : Number |
| InsecureIVorNonceSource.java:123:28:123:43 | nextInt(...) : Number | semmle.label | nextInt(...) : Number |
| InsecureIVorNonceSource.java:126:35:126:63 | new GCMParameterSpec(...) : GCMParameterSpec | semmle.label | new GCMParameterSpec(...) : GCMParameterSpec |
| InsecureIVorNonceSource.java:126:61:126:62 | iv : byte[] [[]] : Number | semmle.label | iv : byte[] [[]] : Number |
| InsecureIVorNonceSource.java:130:51:130:56 | ivSpec | semmle.label | ivSpec |
| InsecureIVorNonceSource.java:138:52:138:62 | randomBytes : byte[] | semmle.label | randomBytes : byte[] |
| InsecureIVorNonceSource.java:141:26:141:36 | randomBytes : byte[] | semmle.label | randomBytes : byte[] |
| InsecureIVorNonceSource.java:141:42:141:43 | iv [post update] : byte[] | semmle.label | iv [post update] : byte[] |
| InsecureIVorNonceSource.java:143:35:143:63 | new GCMParameterSpec(...) : GCMParameterSpec | semmle.label | new GCMParameterSpec(...) : GCMParameterSpec |
| InsecureIVorNonceSource.java:143:61:143:62 | iv : byte[] | semmle.label | iv : byte[] |
| InsecureIVorNonceSource.java:147:51:147:56 | ivSpec | semmle.label | ivSpec |
| InsecureIVorNonceSource.java:155:52:155:62 | randomBytes : byte[] | semmle.label | randomBytes : byte[] |
| InsecureIVorNonceSource.java:158:14:158:43 | copyOf(...) : byte[] [[]] : Object | semmle.label | copyOf(...) : byte[] [[]] : Object |
| InsecureIVorNonceSource.java:158:28:158:38 | randomBytes : byte[] | semmle.label | randomBytes : byte[] |
| InsecureIVorNonceSource.java:160:35:160:63 | new GCMParameterSpec(...) : GCMParameterSpec | semmle.label | new GCMParameterSpec(...) : GCMParameterSpec |
| InsecureIVorNonceSource.java:160:61:160:62 | iv : byte[] [[]] : Object | semmle.label | iv : byte[] [[]] : Object |
| InsecureIVorNonceSource.java:164:51:164:56 | ivSpec | semmle.label | ivSpec |
| InsecureIVorNonceSource.java:174:52:174:62 | randomBytes : byte[] | semmle.label | randomBytes : byte[] |
| InsecureIVorNonceSource.java:175:16:175:26 | randomBytes : byte[] | semmle.label | randomBytes : byte[] |
| InsecureIVorNonceSource.java:180:21:180:32 | generate(...) : byte[] | semmle.label | generate(...) : byte[] |
| InsecureIVorNonceSource.java:182:34:182:56 | new IvParameterSpec(...) : IvParameterSpec | semmle.label | new IvParameterSpec(...) : IvParameterSpec |
| InsecureIVorNonceSource.java:182:54:182:55 | iv : byte[] | semmle.label | iv : byte[] |
| InsecureIVorNonceSource.java:186:51:186:56 | ivSpec | semmle.label | ivSpec |
| InsecureIVorNonceSource.java:194:26:194:30 | bytes : byte[] | semmle.label | bytes : byte[] |
| InsecureIVorNonceSource.java:195:16:195:20 | bytes : byte[] | semmle.label | bytes : byte[] |
| InsecureIVorNonceSource.java:200:21:200:51 | generateInsecureRandomBytes(...) : byte[] | semmle.label | generateInsecureRandomBytes(...) : byte[] |
| InsecureIVorNonceSource.java:202:34:202:56 | new IvParameterSpec(...) : IvParameterSpec | semmle.label | new IvParameterSpec(...) : IvParameterSpec |
| InsecureIVorNonceSource.java:202:54:202:55 | iv : byte[] | semmle.label | iv : byte[] |
| InsecureIVorNonceSource.java:206:51:206:56 | ivSpec | semmle.label | ivSpec |
subpaths
testFailures
| InsecureIVorNonceSource.java:42:21:42:21 | 1 : Number | Unexpected result: Source |

View File

@@ -11,7 +11,7 @@ public class InsecureIVorNonceSource {
// BAD: AES-GCM with static IV from a byte array
public byte[] encryptWithStaticIvByteArrayWithInitializer(byte[] key, byte[] plaintext) throws Exception {
byte[] iv = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 };
byte[] iv = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 }; // $Source
GCMParameterSpec ivSpec = new GCMParameterSpec(128, iv);
SecretKeySpec keySpec = new SecretKeySpec(key, "AES");
@@ -54,8 +54,8 @@ public class InsecureIVorNonceSource {
// BAD: AES-GCM with static IV from a multidimensional byte array
public byte[] encryptWithOneOfStaticIvs01(byte[] key, byte[] plaintext) throws Exception {
byte[][] staticIvs = new byte[][] {
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 },
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 42 }
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 }, // $Source
{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 42 } // $Source
};
GCMParameterSpec ivSpec = new GCMParameterSpec(128, staticIvs[1]);
@@ -70,8 +70,8 @@ public class InsecureIVorNonceSource {
// BAD: AES-GCM with static IV from a multidimensional byte array
public byte[] encryptWithOneOfStaticIvs02(byte[] key, byte[] plaintext) throws Exception {
byte[][] staticIvs = new byte[][] {
new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 },
new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 42 }
new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5 }, // $Source
new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 42 } // $Source
};
GCMParameterSpec ivSpec = new GCMParameterSpec(128, staticIvs[1]);
@@ -191,7 +191,7 @@ public class InsecureIVorNonceSource {
public byte[] generateInsecureRandomBytes(int numBytes) {
Random random = new Random();
byte[] bytes = new byte[numBytes];
random.nextBytes(bytes);
random.nextBytes(bytes); // $Source
return bytes;
}