CBC IV=Key Recovery Attack
- •
What it is
- •
A CBC implementation that (mis)uses the encryption key as the IV leaks the key itself. Since CBC decryption is (with ), decrypting two all-zero ciphertext blocks through the oracle and XORing the resulting plaintexts cancels out the identical term from both, leaving exactly the IV — which equals the key.
- •
- •
When to apply
- •
A CBC implementation sets
IV = KEY(or otherwise derives the IV predictably/reversibly from the key), and exposes a decryption oracle you can feed arbitrary ciphertext.
- •
- •
Math
- •
. With : .
- •
- •
Worked example
- •
Sending two all-zero 16-byte ciphertext blocks to a
IV = KEYdecryption oracle and XORing the two returned plaintext blocks recovered the exact 16-byte key (YELLOW SUBMARINE), byte for byte, with no brute-forcing at all.
- •
- •
Python
- •
plaintext = decrypt_oracle(b"\x00" * 32) # two all-zero blocks key = xor(plaintext[:16], plaintext[16:32])
- •
- •
Related
- •
Cards
- •
Why does decrypting two all-zero ciphertext blocks reveal the IV when IV = KEY?
- •
Both blocks share the identical term, which cancels out when the two plaintexts are XORed together, leaving just the IV (= the key).
- •
- •
What's the underlying design mistake this attack exploits?
- •
Reusing the secret key as the IV, so recovering the IV is equivalent to recovering the key.
- •
- •