Encryption is usually described as "nobody else can read it." Give the definition of what a block-cipher mode of operation actually guarantees, and explain why a ciphertext an attacker can modify in a predictable way is insecure even when they can never read it.
answer
- mode ≠ cipher: the mode is where breaks happen
- IND-CPA hides content, not length, not tampering
- flip ciphertext bit → flip plaintext bit (keystream modes)
- AEAD: plaintext OR fail, never partial
- AEAD gives no freshness — bind a counter in the AAD
basics
~20 sA mode gives confidentiality only — it hides content, not length and not authenticity. Unauthenticated ciphertext is malleable: an attacker can flip plaintext bits blindly. Authenticated encryption adds a tag, so any modified ciphertext is rejected instead of decrypted.
solid answer
~50 sA block cipher only permutes one fixed-size block. A **mode of operation** is the construction that turns it into a scheme for arbitrary-length messages, and the property it targets is confidentiality (indistinguishability under chosen-plaintext attack): given two equal-length messages you cannot tell which was encrypted. Note what that definition does *not* cover — length, and modification. Unauthenticated modes are **malleable**. In counter-style modes the ciphertext is plaintext XOR keystream, so flipping ciphertext bit *i* flips plaintext bit *i* exactly: `amount=00001` becomes `amount=99999` without the key. In CBC, corrupting one block garbles it but flips *chosen* bits of the next, so you trade one garbage block for control of the next. Blocks can also be dropped, reordered or replayed. **Authenticated encryption (AEAD)** adds integrity of ciphertexts: decryption returns plaintext *or* fail, never partial output, and associated data binds the ciphertext to its context. Confidentiality without integrity is not a usable security property.
code
text · 10 linesplaintext : role=user;credit=00010
keystream : K K K K K K K K K K K K K K K
ciphertext: P xor K
attacker knows the layout, wants credit=99910:
delta = "00010" xor "99910" (byte-wise, over the 5 known bytes)
C' = C xor (0...0 | delta | 0...0)
receiver decrypts C' -> role=user;credit=99910
no key involved; only the layout had to be guessedgo deeper
Be able to say that encryption hides content but does not by itself stop tampering, and that authenticated encryption adds a tag which makes decryption fail on any modification.
Explain malleability concretely for a keystream mode and for CBC, define the AEAD interface including associated data, and state that decryption is all-or-nothing.
Frame it as IND-CPA versus INT-CTXT, argue why chosen-ciphertext security is the property that actually matters for a service that decrypts attacker-supplied input, and point out the freshness gap.
Treat the choice as a protocol decision: what the associated data must bind, where replay and rollback are handled, what length leakage costs in this product, and why hand-rolled compositions are a liability you would not accept in a design review.
## What a "mode of operation" is A block cipher is a keyed permutation on one fixed-size block — typically 128 bits. On its own it is not an encryption scheme: it can only turn 16 bytes into 16 bytes. A **mode of operation** is the construction that lifts that primitive into a scheme for messages of arbitrary length. The mode decides how blocks relate to each other (chaining, as in CBC), or whether the cipher is used to generate a keystream that is XORed with the plaintext (counter-style modes), how a final partial block is handled (padding, ciphertext stealing, or nothing at all in a stream-like mode), and whether the output is randomized by an initialization vector or nonce. The cipher is almost never the weak part. Essentially every real-world break in this area is a **mode-level or composition-level** failure, not a break of the underlying permutation. ## The property a mode actually provides The standard goal is **indistinguishability under chosen-plaintext attack (IND-CPA)**: an adversary who can have plaintexts of their choice encrypted still cannot tell which of two *equal-length* messages a challenge ciphertext corresponds to. Two things fall out of that definition that candidates routinely miss. First, *equal-length*. No conventional mode hides message length. Length alone can be the secret — a yes/no answer, an autocomplete suggestion, a compressed payload whose size depends on how much a guessed secret matched. Second, and more importantly, the definition says nothing whatsoever about what happens when the adversary **modifies** a ciphertext and submits it back. IND-CPA is a passive-reading property. It is not a property about tampering. ## Malleability, concretely Unauthenticated modes are *malleable*: a controlled change to the ciphertext produces a controlled change to the plaintext. - **Counter/stream-style modes.** Ciphertext = plaintext XOR keystream, byte-aligned. Flip ciphertext bit *i* and plaintext bit *i* flips. The attacker never learns the plaintext, but if they can guess the layout — a fixed-offset field, a serialized struct, `role=user`, a length prefix — they rewrite it exactly. No key needed. - **CBC.** Modifying a block of ciphertext turns the corresponding plaintext block into unpredictable garbage, but XORs your chosen delta into the *next* plaintext block. So the attacker spends one block of noise to gain bit-level control of the following block. - **All of them.** Whole blocks or records can be truncated, duplicated, reordered, or replayed from an older session, because nothing binds a ciphertext to its position, its record, or its point in time. ## "It will just decrypt to garbage and my parser will reject it" This is an argument that the attack is noisy, not that it is prevented, and it fails for three reasons. 1. The attacker needs one bit of feedback. A distinguishable error, a different response time, a retry, a log entry, a downstream side effect — any of these makes the service an oracle, and oracles turn tamper-only access into full plaintext recovery. 2. Many plaintexts tolerate corruption: bitmaps, fixed-offset records, bitmask flags, media containers, and anything where the field you care about is far from the field that got garbled. 3. The attacker gets unlimited attempts unless something rate-limits them. ## Authenticated encryption An **AEAD** scheme has the interface `encrypt(key, nonce, plaintext, associated_data) -> ciphertext+tag` and `decrypt(key, nonce, ciphertext+tag, associated_data) -> plaintext OR FAIL`. It provides IND-CPA **plus integrity of ciphertexts (INT-CTXT)**: an adversary cannot produce any ciphertext the sender did not produce that decrypts successfully. The standard result is that IND-CPA together with INT-CTXT gives security against chosen-ciphertext attack — which is exactly the class the oracles above live in. The all-or-nothing part of the contract is load-bearing. If an implementation releases plaintext bytes before verifying the tag — streaming decryption of a large object, for instance — it has reintroduced the malleability it paid to remove. **Associated data** is the second half of the interface: bytes that are *not* encrypted but *are* covered by the tag. Version number, key identifier, nonce, record id, tenant id, file path. This is how a ciphertext gets bound to its context, so a valid record cannot be lifted from one row, tenant or file and pasted into another. ## Authenticity is not a signature A symmetric tag proves the ciphertext was produced by *someone holding the key*. Both parties hold it, so there is no non-repudiation and nothing a third party can adjudicate — that asymmetry belongs to digital signatures, not to modes. ## Confidentiality, integrity, authenticity, freshness An AEAD gives the first three, within the scope of one key. It gives **no freshness**. A complete, valid ciphertext replayed later is still valid; an old record restored from a backup verifies perfectly. Freshness requires a sequence number, timestamp, or session-bound value carried in the associated data and *checked* by the receiver. ## The ladder Structural separation (pick a standard authenticated mode; the composition is not yours to invent) beats escaping/transformation-style fixes (hand-building an encrypt-then-MAC composition — correct in principle, but now you own the ordering, the tag comparison and exactly which bytes are covered), which beats validation (plaintext sanity checks after decryption — heuristic), which beats detection (alerting on decryption failures). Each rung down trades a guarantee for a heuristic.
- If an attacker cannot read the plaintext at all, how do they know which bytes to flip?They usually do not need to read it — they need to know the format. Message layouts are fixed by the application: a serialized struct, a URL-encoded cookie, a fixed-width record, a length prefix. If the attacker can also cause a message to be encrypted (they registered the account, they chose the filename), they know the plaintext exactly and can compute the delta precisely. Where the layout is unknown they can probe it, since malleability plus any observable difference in behaviour gives them feedback.
- Does adding a checksum such as CRC32 inside the plaintext give you integrity?No. A CRC is a linear, unkeyed function, so in a keystream mode the attacker can adjust the encrypted CRC bytes to match the change they made to the encrypted payload — this is a historically famous break. Even a cryptographic hash placed inside the plaintext does not help, because the attacker can compute the hash of their intended plaintext; nothing binds it to the key. Integrity requires a keyed construction: a MAC or an AEAD tag.
- Where does an AEAD tag stop helping?It stops at anything outside a single message under a single key. It does not hide message length, does not prove ordering or recency (a replayed valid ciphertext still verifies), does not stop whole-record deletion when tags are per-record, and does not bind a record to its location unless you put that location in the associated data. It also assumes the key is secret, so it says nothing about a compromised process.
An unauthenticated ciphertext is a sealed envelope with no signature and no tamper tape: nobody can read the letter in transit, but anyone can shake out a word and slide a new one in, and the recipient has no way to notice.
saying these in an interview costs you the question
- "If they can't read it, they can't do anything with it" — malleability is a modification attack, not a reading attack.
- Believing a CRC or a plain hash inside the plaintext provides integrity.
- Thinking AES is 'secure' independent of the mode, so the mode is a performance decision.
- Claiming an authenticated mode prevents replay of an entire valid message.
- Streaming out decrypted bytes before the tag has been verified, then calling the result authenticated encryption.