Static IV/nonce (ARCH6114)
Key ruby.security.static-iv · Severity error · Category security · CWE CWE-329
Passing a constant or zero IV/nonce to a cipher destroys semantic security; reusing the same IV in CBC/CTR/GCM leaks plaintext and can enable key recovery under GCM.
Incorrect
Section titled “Incorrect”cipher = OpenSSL::Cipher.new("aes-256-gcm")cipher.encryptcipher.key = keycipher.iv = "\x00" * 12Correct
Section titled “Correct”cipher = OpenSSL::Cipher.new("aes-256-gcm")cipher.encryptcipher.key = keyiv = cipher.random_ivGenerate a cryptographically random, unique IV/nonce per encryption and store it alongside the ciphertext.