Skip to content

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

FieldValue
IDCODE-0184
CategoryCrypto
SeverityCRITICAL
CWECWE-323
ConfidenceMEDIUM
ImpactHIGH
LikelihoodHIGH
ExploitabilityEASY
TagsCryptographic Misuse
OWASPA3:2017-Sensitive Data Exposure, A02:2021-Cryptographic Failures

References