Changelog - 2026-11-07
AES uses a fresh random IV for every encryption
Security Breaking ChangeIn one line. AES.encrypt took a caller-chosen iv. An IV reused under aes-256-gcm breaks confidentiality and integrity, so the option is removed: every encryption draws a fresh random IV.
What changed
- No
ivoption.AES.encryptdraws 16 random bytes fromcrypto.getRandomValueson every call and writes them into the ciphertext, as it already did when noivwas passed. - Passing
ivis refused. A call toencryptordecryptthat passesivthrowsThe iv option was removed, so nobody believes a chosen IV is still used.decryptused to ignore a suppliedivwithout a word; it refuses it now too. - Existing ciphertext still decrypts.
decryptreads the IV from the ciphertext, and that is unchanged, so what was written under a fixed IV, in the same format, still reads. Tests cover an envelope sealed under a constant IV, foraes-256-cbcandaes-256-gcm, and the recorded fixtures. - Not readable, and never was since 3 August 2026. Ciphertext written before the PBKDF2 key derivation and key ids (commit
5ea37908, the scheme where the key was the secret padded or truncated) is rejected on its version byte bydecrypt. That did not change here. - Unchanged. The ciphertext format, key derivation, keyrings,
kdfSaltandkdfIterations, and every other option.
Who is affected
- Callers that pass
ivtoAES.encrypt. They get an exception. Remove the option; the IV is chosen for them and stored in the ciphertext. - Callers that pass
ivtodecrypt. It was ignored; it is refused now. Remove it. - Tests that relied on a fixed IV for a known output. Stub
crypto.getRandomValuesfor the call, or compare by decrypting. - Everyone else. No action needed.
Breaking changes
WARNING
A call to AES.encrypt or AES.decrypt that passes iv throws.
Before:
typescript
const sealed = await aes.encrypt({ message, secret, opts: { iv: someBuffer } });After:
typescript
const sealed = await aes.encrypt({ message, secret });
const plain = await aes.decrypt({ message: sealed, secret }); // reads the IV from `sealed`Details
| File | Package |
|---|---|
src/modules/crypto/algorithms/aes.algorithm.ts | helpers |
src/modules/crypto/algorithms/base.algorithm.ts | helpers |