Section 20.19

Tree 19: “What if the active or recovery key is compromised?”

Setting

A sensor gateway is a small device that collects readings from sensors and passes them on. In this invented example, the gateway also runs a small decision program, and a publisher, the one party authorized to change the gateway’s policy, sends it new programs and management requests. Everything travels through a phone that relays the bytes over a Bluetooth radio link. Each request carries a tag computed with HMAC §5.8 (hash-based message authentication code), a message authentication code §5.7 (MAC): a function that computes a short value, the tag, from a secret key and a message, so that someone without the key should have only a negligible chance of creating a valid tag for a new request.

The gateway runs the publisher’s decision program in a virtual machine §2.3 (VM), a part of its software that carries out the program’s instructions one at a time and refuses any instruction that would touch memory outside the program’s own. The program decides which management requests the gateway allows.

The gateway holds two secret keys. KaK_a is the active key, the key whose tags the gateway accepts on ordinary requests; it belongs to generation number g=7g = 7, where the generation number counts key replacements. KrK_r is the recovery key §5.31: a separate key, kept offline at the publisher, whose tags authorize one recovery action, installing a new active key. The publisher computes both keys from a root secret RR with a key derivation function §5.20 (KDF), an algorithm §14.1 that turns one secret and a public label into a key: Ka=KDF(R,“active-7”)K_a = \mathrm{KDF}(R, \text{``active-7''}) and Kr=KDF(R,“recovery”)K_r = \mathrm{KDF}(R, \text{``recovery''}).

After a compromise, damage spreads along two kinds of link. A derivation link runs from a secret to every key computed from it: whoever knows RR can compute KaK_a. An authority link runs from a key to every key it can install or revoke: whoever holds KrK_r can make the gateway accept a new active key. An attacker reaches every key along either kind of link.

Short answer

A compromise gives the attacker every key derivable from the stolen secret and every power the stolen key carries, including the power to install other keys. A stolen active key KaK_a lets the attacker make any request KaK_a may authorize, until the gateway stops accepting KaK_a. A stolen recovery key KrK_r is worse: it can replace whatever active key exists. A stolen root secret exposes every key derived from it. Recovery needs trust the attacker cannot reach, such as an independent key or physical access to the gateway.

Follow-up questions

Active-key compromise

An attacker who holds the active key KaK_a can make every request that KaK_a may authorize, until the gateway stops accepting KaK_a. Here a sensor gateway accepts its publisher’s requests when they carry a tag computed with KaK_a by HMAC (hash-based message authentication code), a message authentication code (MAC) that only a holder of the key can compute. HMAC shows that the sender knew KaK_a; it cannot tell the publisher from a second holder. Because KaK_a is shared by both ends, the attacker can also pose as the gateway toward the publisher, if the gateway’s replies are tagged with KaK_a.

What the attacker can do depends on what KaK_a authorizes:

KaK_a alone does not reveal the content of past messages, because a MAC key authenticates and does not encrypt. That changes if KaK_a was also used to encrypt something, for example a replacement key wrapped under KaK_a: an attacker who recorded that transfer learns the replacement key as well.

Recovery-key compromise

An attacker who holds the recovery key KrK_r can replace the gateway’s active key with a key of its own, without ever learning the current active key KaK_a. The recovery key is a separate secret. A request that carries a tag computed with KrK_r by a message authentication code (MAC), a short check value that only a holder of KrK_r can compute, may install a new active key. Example: the attacker chooses a key KxK_x and sends “recovery: install KxK_x as generation 9”, tagged with KrK_r. The gateway checks the tag and accepts the request, and from then on accepts only tags made with KxK_x. The publisher’s KaK_a is now useless.

No cryptography was broken. The MAC that produced the tag remains secure; the attacker simply used a power that the design granted to KrK_r. Such a power is an authority link: holding one key lets its holder install or revoke another.

Replacing the active key does not close that link, because the attacker can repeat the recovery and replace the new active key as well. The repair must replace KrK_r itself, through trust the attacker does not hold: for example a higher-level key, kept offline, that may replace KrK_r, or physical access to the gateway, such as a button press or a wired connection. Every gateway that accepts KrK_r must learn the new rule, including gateways that are switched off when the repair begins.

Root compromise

If a root secret RR is exposed, every key derived from RR with public inputs is exposed too, including keys that have not been derived yet. A key derivation function (KDF) computes a key from a secret and a label. Suppose a sensor gateway’s active key is Ka=KDF(R,“active-7”)K_a = \mathrm{KDF}(R, \text{``active-7''}) and its recovery key, which may install a new active key, is Kr=KDF(R,“recovery”)K_r = \mathrm{KDF}(R, \text{``recovery''}), with public labels. An attacker who learns RR computes both. It can also compute KDF(R,“active-8”)\mathrm{KDF}(R, \text{``active-8''}), so a key change that derives the next key from RR hands the attacker the next key at the same moment. A new label adds no secrecy, because labels are public.

Follow both kinds of link to their end. From RR, derivation links reach every key computed from RR. From each of those keys, authority links reach every key that it may install or revoke. Here KrK_r is computed from RR, so the attacker also holds the power to replace any active key the publisher installs later.

Recovery needs fresh secret material that the attacker never saw, produced by a random source the attacker cannot observe, and installed through a path the attacker can neither control nor replace with its own. While the attacker holds KrK_r, it can substitute its own “fresh” key for the publisher’s. When every authority in the design traces back to RR, no message to the gateway can restore trust. Only an action outside the compromised keys can, such as an operator with physical access setting the gateway up again with a new root.

Does a new independent active key provide forward secrecy §5.33?

No: an independent new key can protect future messages, forward secrecy is about past ones, and neither property follows from independence alone. A key is independent of another key when it was made from fresh randomness, so that knowing one tells nothing about the other.

Forward secrecy is a property of a protocol: an attacker who later learns the long-term keys §7.28 still cannot recover the keys of sessions that ended before. A protocol obtains it by agreeing a fresh key for each session, for example by Diffie–Hellman key agreement §19.1.4 with new private values, and by erasing those values afterwards. Post-compromise security §5.34 points the other way in time: after an attacker has learned a party’s secrets, security returns for later messages once the parties complete an exchange that the attacker neither observes nor controls. The Double Ratchet algorithm of the Signal messaging protocol obtains it by mixing new Diffie–Hellman values into its keys as messages flow.

Apply this to a sensor gateway whose active key KaK_a authenticates requests with a message authentication code (MAC) and is replaced by a new key KpK_p:

What must an operational recovery plan specify?

An operational recovery plan must say, before any compromise happens, how a compromise is detected, how far it reaches, which trust survives it, and how every affected device is brought back under that trust. For a fleet of sensor gateways whose requests are authenticated by a message authentication code (MAC) under an active key, with a separate recovery key that may install a new active key, the plan specifies:

If every relevant authority is compromised, the plan must name the trust to be set up again from outside, for example an operator installing new keys over a wired connection. Another exchange of tagged messages under a key the attacker holds cannot establish trust, because the attacker can compute the same tags.

Related entries: Recovery key (§5.31), Forward secrecy (§5.33), Post-compromise security (§5.34), Recovery authority (§1.46), Key derivation function (KDF) (§5.20), Key revocation (§5.32), TUF: surviving limited signing-key compromise (§21.10).