VNX-329: Predictable IV derived from the key or a non-cryptographic generator
Reports block-cipher IVs that are the key (or a slice of it) or come from a non-cryptographic generator or the clock, in Python, Java, Kotlin, Go and Node.js. Constant IVs are VNX-CRYPTO-010's and VNX-JAVA-020's.
| Field | Value |
|---|---|
| Rule ID | VNX-329 |
| Severity | High |
| SARIF level | error |
| Kind | sast |
| Languages | Go, Java, Kotlin, JavaScript / TypeScript, Python |
| CWE | CWE-329 |
| CAPEC | CAPEC-66 |
| ATT&CK | T1190 |
| CWSS vector | CWSS:1.0/TI:H/AP:RU/AL:S/IC:N/FC:LT/RP:RU/RL:S/AV:L/AS:N/IN:A/SC:A/BI:H/DI:H/EX:H/EC:N/P:H |
| Tags | crypto iv-reuse predictable-iv cwe-329 |
| Source | internal/sast/rules/vnx-329.rego |
Overview
VNX-329 maps to CWE-329: Generation of Predictable IV with CBC Mode. It reports an IV or nonce that is predictable because it is derived from the encryption key, drawn from a non-cryptographic generator, or built from the clock.
Why This Matters
A predictable CBC IV allows chosen-plaintext attacks (BEAST is the famous one). Using the key as the IV is worse: an attacker who can get one chosen ciphertext decrypted recovers the key itself.
What Gets Flagged
# FLAGGED: the IV is the key
AES.new(key, AES.MODE_CBC, key)
iv = key[:16]
# FLAGGED: the IV comes from the random module
iv = random.randbytes(16)
// FLAGGED
new IvParameterSpec(keyBytes)
byte[] ivBytes = Arrays.copyOf(secretKey, 16);
rnd.nextBytes(iv); // rnd is a java.util.Random
// FLAGGED
cipher.NewCBCEncrypter(block, key[:aes.BlockSize])
rand.Read(iv) // math/rand
// FLAGGED
crypto.createCipheriv('aes-256-cbc', key, key.slice(0, 16));
What Is Not Flagged
- IVs from
os.urandom,secrets,get_random_bytes,SecureRandom,crypto/rand,randomBytesorgetRandomValues. - IVs read from the ciphertext (
blob[:16]). - Constant IVs, which VNX-CRYPTO-010 and VNX-JAVA-020 report.
- Names that only contain the letters (
keys,keyword,keystore), comments, string literals and test files.
Remediation
Generate a fresh IV for every message from a CSPRNG and send it with the ciphertext, or use an AEAD mode with a random or counter nonce that is never reused under the same key.
References
Suppressing this rule
Put a nosec comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file’s language (#, //, -- or ;):
# nosec vnx-329
// nosec vnx-329
Or record an ignore rule: vulnetix ignore add --rule vnx-329 --reason "...". See Suppressing findings.