Zum Inhalt springen

ECB cipher mode (ARCH310)

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

Key dotnet.security.ecb-mode · Severity error · Category security · CWE CWE-327

ECB mode maps identical plaintext blocks to identical ciphertext, exposing data patterns. Use an authenticated mode with a random IV.

using var aes = Aes.Create();
aes.Mode = CipherMode.ECB;
var encryptor = aes.CreateEncryptor();
using var aes = new AesGcm(key, AesGcm.TagByteSizes.MaxSize);
RandomNumberGenerator.Fill(nonce);
aes.Encrypt(nonce, plaintext, ciphertext, tag);

Replace CipherMode.ECB with an authenticated mode (AES-GCM) and a random per-message nonce/IV.