GCM Nonce Reuse Risk
Description
Detected a potentially reused or static IV (nonce) in GCM mode. GCM requires a unique, random IV for each encryption operation. Reuse of IVs in GCM mode can lead to catastrophic loss of confidentiality and data integrity.
Examples
Insecure Code
java
GCMParameterSpec spec = new GCMParameterSpec(128, new byte[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12});Secure Code
java
SecureRandom random = new SecureRandom(); byte[] iv = new byte[12]; random.nextBytes(iv); GCMParameterSpec spec = new GCMParameterSpec(128, iv);Remediation
Use `SecureRandom.nextBytes()` to generate a fresh IV.
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0184 |
| Category | Crypto |
| Severity | CRITICAL |
| CWE | CWE-323 |
| Confidence | MEDIUM |
| Impact | HIGH |
| Likelihood | HIGH |
| Exploitability | EASY |
| Tags | Cryptographic Misuse |
| OWASP | A3:2017-Sensitive Data Exposure, A02:2021-Cryptographic Failures |