Static initialization vector (ARCH312)
Ce contenu n’est pas encore disponible dans votre langue.
Key dotnet.security.static-iv · Severity error · Category security · CWE CWE-329
Reusing a fixed or zero IV breaks semantic security and allows comparison across ciphertexts. Generate a fresh random IV per encryption.
Incorrect
Section titled “Incorrect”using var aes = Aes.Create();aes.IV = new byte[16]; // all zeros, reused every timeCorrect
Section titled “Correct”using var aes = Aes.Create();aes.GenerateIV(); // fresh random IV per message; store it alongside ciphertextGenerate a new IV per message with GenerateIV() or RandomNumberGenerator and store it with the ciphertext.