ECB leaks structure. CBC does not — and neither one stops tampering.

Same key, same picture, two modes. ECB encrypts every 16-byte block on its own, so equal blocks give equal ciphertext and the shape survives. CBC XORs each block with the previous ciphertext first. Panel 2 is the sting: that same XOR is what lets an attacker edit a CBC token without the key.

1 · The picture

Plaintext
A padlock drawn in four flat colours.

ECB ciphertext
ECB ciphertext: the padlock is still visible.

CBC ciphertext
CBC ciphertext: uniform noise.

Every byte — plaintext or ciphertext — is drawn through the same 4-colour palette (its top two bits). The cipher is a toy 16-byte permutation written for this page: 6 rounds of substitute, mix, shuffle. It stands in for AES so that the mode is the only thing changing. It is not AES and it is not secure.

2 · The session token

A 32-byte token — two blocks — encrypted with CBC. The IV and the ciphertext travel in the clear, so both are attacker-editable. Pick a byte, then a bit.

byte index
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
IV — public, editable (click a byte)
C0 — ciphertext block 0, editable (click a byte)
C1 — ciphertext block 1, left alone

Which bit to flip in the selected byte

P0 = D(C0) ⊕ IV
P1 = D(C1) ⊕ C0

↯ marks a byte that changed. · is an unprintable byte.

Same toy 16-byte permutation as panel 1 — not AES, and not secure. Nothing here depends on which block cipher is underneath: the attack is on the mode, and it works identically against real AES-CBC. What stops it is authentication — an HMAC over the ciphertext, or AES-GCM.