Zum Inhalt springen

Static IV/nonce (ARCH6114)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

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.

cipher = OpenSSL::Cipher.new("aes-256-gcm")
cipher.encrypt
cipher.key = key
cipher.iv = "\x00" * 12
cipher = OpenSSL::Cipher.new("aes-256-gcm")
cipher.encrypt
cipher.key = key
iv = cipher.random_iv

Generate a cryptographically random, unique IV/nonce per encryption and store it alongside the ciphertext.