Section 1.34

End-to-end security

Definition

End-to-end security is protection that the original sender of data applies and the final receiver checks, so that it holds however many systems carry the data in between. Those intermediate systems, called relays, such as routers, gateways, servers and phone apps that pass messages on, forward the protected bytes but hold no key that would let them change the bytes undetected, or read them if they are encrypted. In hop-by-hop security, by contrast, each link is protected separately, and every relay holds the data unprotected and could change it.

The idea

A server sends a configuration command to a sensor. The command travels from the server to a cloud message service, from there to a phone app, and from the phone over Bluetooth to the sensor. Each of the three links has its own secure channel, for example TLS (Transport Layer Security, the protocol behind secure web connections) on the internet links and Bluetooth’s own link encryption on the last link. Each channel protects the command only while it crosses its link. At the cloud service and at the phone, the channel ends: the relay decrypts the command, holds it in plain form and sends it on through the next channel. A compromised phone app can change “threshold 30” into “threshold 90”, and the sensor receives a correctly protected Bluetooth message from the phone. With hop-by-hop protection, every relay must be trusted.

End-to-end protection removes that need. The server attaches a tag from a MAC (message authentication code §5.7), a short value that only a holder of the secret key can compute over exactly these bytes, using a key that only the server and the sensor know. The relays pass the command and its tag along. The sensor recomputes the tag and acts only if it matches. A relay that changes a byte cannot compute the matching tag, so the sensor detects the change. The per-link channels can stay in place, but the sensor no longer depends on them for integrity §1.9, the assurance that the command arrives unchanged.

A clear, tamper-evident sealed pouch passed from courier to courier is a fair picture. Any courier can carry the pouch and read the letter through the plastic, but none can change the letter without breaking the seal, and the addressee checks the seal. The picture stops in three places. A courier can still lose the pouch, delay it, or deliver an old pouch a second time. The address label on the outside can be changed unless the address is also sealed inside. And hiding the letter needs an opaque pouch, which corresponds to encryption.

The idea has a classic statement in system design. In “End-to-End Arguments in System Design” (1984), Saltzer, Reed and Clark argued that a function such as reliable or secure delivery can be implemented completely and correctly only with the knowledge and help of the applications at the endpoints [420]. Checks inside the network can improve performance, but they cannot replace the check at the end.

How it works

  1. Keys at the ends only. The origin and the destination obtain keys that no relay holds: either a secret key shared by exactly these two parties, for a MAC, or a key pair in which the origin keeps the private key and the destination holds the public key, for a digital signature §5.14, a value that only the holder of the private key can compute and that anyone with the public key can check. How the keys are distributed decides who really counts as an end.

  2. Protect the content and its context. The origin builds the object: the content, plus every field that affects what the destination will do with it, such as the identifier of the target device, the operation and a counter that increases with every object. The origin computes the tag or signature over all of these bytes. The exact set of bytes covered is the object’s authentication coverage §5.41. To hide the content from relays as well, the origin uses authenticated encryption §5.16, which encrypts the content and computes a tag in one operation.

  3. Forward. Relays carry the object. They may wrap it in their own per-link protection and add or remove their own routing headers, but they do not need to touch the protected bytes.

  4. Check at the destination before acting. The destination verifies the tag over the exact bytes it received, checks that the target field names itself, checks that the counter is higher than the last counter it accepted, and only then acts.

End-to-end protection takes away one power of the relays, the power to change or forge protected content, and, with encryption, a second one, the power to read it. Relays keep every other power:

Worked example

A server sends the command “set threshold to 30” to device number 7. The object contains the target identifier 7, the counter value 41 and the command. The server appends a 16-byte (128-bit) MAC tag computed over all three with a key K7K_7 that only the server and device 7 know. Device 7 last accepted counter 40. A compromised relay tries five things.

  1. Change the threshold to 90. The relay does not know K7K_7, so it must guess a tag for the changed object. For a secure MAC with 128-bit tags, each guess is right with probability about 2−128≈2.9×10−392^{-128} \approx 2.9 \times 10^{-39}. Even 101210^{12} guesses succeed with probability at most 1012×2−128≈2.9×10−2710^{12} \times 2^{-128} \approx 2.9 \times 10^{-27}. The change is detected.

  2. Deliver the object twice. The first delivery is accepted, and device 7 records counter 41. The second delivery carries 41, which is not higher than 41, so device 7 rejects it. Without the counter, the second delivery would be accepted, because its tag is valid.

  3. Redirect the object to device 8. Device 8 checks the tag with its own key K8K_8, and the check fails. Had devices 7 and 8 shared one key, the tag would pass, and only the protected target identifier 7, which is not device 8’s own, would stop the command. A target identifier carried only in an unprotected routing header would not stop it.

  4. Drop the object. Device 7 never learns that a command existed. End-to-end integrity cannot prevent this; only acknowledgments and timeouts §9.34 at the server can reveal it.

  5. Read the object. A MAC hides nothing, so the relay learns the threshold. Only end-to-end encryption would prevent that.

Finally, suppose the relay is the cloud service, and the service was given K7K_7 so that it could check commands on the way. The relay can now compute valid tags itself, and device 7 cannot tell the relay’s commands from the server’s. Calling the design end-to-end is then wrong: the location of the keys, not the network diagram, decides where the ends are.

Stated precisely

Let OO be the origin, DD the destination and kk the key that protects the object. For a MAC, kk is a secret key; for a digital signature, kk is the private key, and DD holds the matching public key. End-to-end integrity is the claim: DD acts on content cc with context xx only if OO produced the pair (c,x)(c, x). The claim holds when all of the following hold.

  1. No party other than OO and DD holds kk; for a signature, no party other than OO holds the private key.

  2. The MAC or signature scheme is unforgeable: without the key, no feasible computation produces a valid tag for a new message except with negligible probability, a probability so small that it can be ignored, even after seeing valid tags on messages of the attacker’s choice.

  3. The protected bytes include every field that affects what DD does.

  4. DD checks the tag before acting and acts on exactly the bytes it checked.

  5. DD itself is not compromised, and neither is OO.

The claim says nothing about how often or when DD receives the object. Freshness needs a counter, a time value or a nonce §5.18 (a value used only once) inside the protected bytes, and state at DD that remembers what was already accepted. End-to-end confidentiality §1.8 is the matching claim for encryption: no party other than OO and DD learns cc, beyond its length and the metadata of its delivery. Neither claim covers availability §1.10.

Limits and common mistakes

End-to-end integrity is not confidentiality. A MAC or a signature leaves the content readable by every relay.

End-to-end protection does not guarantee delivery. Relays can drop or delay objects, and the destination cannot tell a dropped object from one that was never sent.

A replay is not a change. A relay that resends an old, intact object passes the tag check; only a freshness check rejects it.

The ends are where the keys are. If a relay holds the key, the relay is an end. If many devices share one key, each of them can create objects that the others accept.

The endpoints remain trusted. Malware at the origin can protect a harmful command correctly, and a bug at the destination can act before checking, or check bytes other than the ones it acts on.

A secure connection to a server is not end-to-end security when the server is a relay. TLS to a cloud service protects the link to that service; the service itself sees, and could change, everything it forwards.

Metadata leaks. Sizes, timing and the identities of the communicating parties stay visible unless something else hides them.

Questions answered

Can a compromised relay alter an authenticated object undetected?

No, a compromised relay cannot alter an end-to-end authenticated object without the destination detecting it, provided four conditions hold: the relay does not hold the authentication §1.6 key (for a digital signature, the private signing key); the MAC (message authentication code) or signature scheme is unforgeable; the authenticated bytes include every field that affects what the destination does; and the destination checks the tag over exactly those bytes before acting. An authenticated object is data that carries a tag, a short value that only a key holder can compute over exactly those bytes. Any change to a covered byte makes the tag check fail, except with negligible probability, such as about 2−1282^{-128} per attempt for a 128-bit tag.

The relay can still do harm without altering anything protected. It can drop or delay the object; deliver an old valid object again, a replay attack that only a counter or other freshness check at the destination stops; change unprotected fields such as a routing header; and read the content unless the content is also encrypted. If the relay holds the key, holds a key that many devices share, or can change the destination’s code or stored keys, the answer becomes yes: the relay can create objects that the destination accepts.

Related entries: Least privilege (§1.15), Authentication coverage (§5.41), Authenticated encryption (AEAD) (§5.16), Replay attack (§1.26), Message authentication code (MAC) (§5.7), Digital signature (§5.14), Trusted computing base (TCB) (§1.4). Further reading: [420].