← PHP / Laravel · Contents

PHP-040 / Advanced

Incorrect cipher modes such as fixed IV or ECB

A02:2021 Cryptographic Failures · CWE-327 Broken Crypto · CWE-329 Non-unpredictable IV

Why is this a problem?

Identical plaintext becomes identical ciphertext, or IV reuse destroys confidentiality.

How to fix it

php
// Use Laravel Crypt (AES-256-CBC + HMAC)
$enc = Crypt::encryptString($data);
// For direct use: AES-256-GCM, generate an IV with random_bytes each time

Further reading