Section 19.3.7

Lifecycle reset and replay across complete reinitialization

Definition

A lifecycle reset is the start of a new lifecycle, the period in which a receiver checks messages with one key and keeps one record of the messages it accepted, such as the last one’s counter. A complete reinitialization erases that record together with the rest of the receiver’s stored state, as a factory reset does. Replay across complete reinitialization is the attack this allows when the key survives the erasure: an old genuine message, sent again, is accepted again, because the receiver no longer remembers accepting it.

Where it fits

Main entry: Replay attack (§1.26).

The Replay attack entry explains the usual defense, a freshness check. The receiver keeps last\mathrm{last}, the counter of the last message it accepted under its key, in storage that survives loss of power. It accepts a message only if two checks pass: the message’s tag, a short value computed from the message with the secret key, verifies; and the counter inside the bytes the tag covers is larger than last\mathrm{last}. That defense assumes that last\mathrm{last} never decreases. A complete reinitialization breaks exactly this assumption, while the key and the tag check stay as they were.

Example. Before the erasure, the receiver accepts a command with counter 1 and stores last=1\mathrm{last} = 1. An attacker records that command. The erasure sets last=0\mathrm{last} = 0 and keeps the same key. The attacker sends the recorded command. Its tag verifies, because the key has not changed, and 1>01 > 0, so the freshness check passes and the command runs a second time. The attacker forged nothing; the state that made the old message ineligible no longer exists.

To separate lifecycles, the receiver’s acceptance test must change in a way that old messages cannot satisfy. Three methods do this.

  1. A new key for each lifecycle. Key provisioning §5.28, the step that installs keys in a device, installs at every reinitialization a fresh key that is independent of the old one. Old messages no longer verify. Deriving the new key again from the same inputs as the old key yields the same key and separates nothing.

  2. A lifecycle number that survives the erasure. The receiver keeps an epoch, a number that counts lifecycles, in storage that the erasure does not touch and that can only increase, such as a monotonic counter §8.28 in one-time programmable memory, whose bits can be set once and never cleared, or in a secure element §5.38, a separate tamper-resistant chip that holds keys and counters. Each message carries the epoch inside the bytes its tag covers, and the receiver accepts only the current epoch. An external server can hold the epoch instead, if its report of the current value is itself authenticated and fresh.

  3. A fresh challenge. The receiver sends a new random value, a nonce §5.18, and accepts only a message whose tag covers that value. No recorded message contains a nonce chosen after the recording. This needs unpredictable random numbers and a round trip, but no state that must survive the erasure.

The epoch forms a two-level, or hierarchical, counter with the message counter. Pairs (epoch, counter) are compared epoch first, as hours are compared before minutes, so the message counter may restart at 0 in each new epoch without any pair repeating. The levels can be stacked: a key generation counter that changes with each new key sits above the epoch, and the key for each generation is derived from a long-term key §7.28 and the generation number with a key derivation function §5.20, an algorithm §14.1 that turns one secret into further keys. Old messages then fail the tag check as well as the counter check.

A label that the receiver does not check separates nothing. A random lifecycle name written only in a log on the managing computer changes neither the key nor any value the receiver compares, so the receiver accepts exactly what it accepted before. The design must also say who may start a new lifecycle: whoever can trigger the erasure can create the conditions for a replay, so the reset command itself needs authentication §1.6 and a freshness check of its own.

Limits and common mistakes

An ordinary restart keeps stored state and does not lower last\mathrm{last}; only erasure does. Erasure followed by provisioning of a new independent key is safe against old messages; erasure that keeps the old key is the dangerous case.

Once the erasure has removed every trusted record of the old lifecycle and the key is unchanged, no reasoning inside the receiver can tell an old message from a new one.

The epoch is only as safe as its storage. If an attacker can restore an older stored value, or if the epoch can wrap around to 0, replay returns.

A new key protects only if the old key is retired. A receiver that still accepts the old key also accepts the old messages.

Questions answered

How can a new lifecycle be separated?

A new lifecycle is separated by changing what the receiver checks, so that no message from the old lifecycle can pass. The problem arises when a receiver erases its replay record, such as the counter of the last accepted message, and keeps its key: a recorded old message then verifies and looks new.

Three methods work. First, install at every reinitialization a fresh key, independent of the old one, and retire the old key, so old messages no longer verify. Second, keep an epoch, a lifecycle number, in storage that the erasure cannot touch and that can only increase, such as a monotonic counter; every message carries the epoch inside the bytes its authentication tag covers, and the receiver accepts only the current epoch. Deriving each lifecycle’s key from a long-term key and the epoch combines the two. Third, have the receiver send a fresh random challenge that every accepted message must contain under its tag. A label that the receiver never checks, such as a lifecycle name kept only in a log on another computer, separates nothing. The command that starts a new lifecycle must itself be authenticated and fresh, because whoever can trigger the erasure can enable the replay.

Related entries: Epoch fencing and stale authority (§19.3.2), Key provisioning (§5.28), Monotonic counter (§8.28), Nonce (§5.18).