---
title: Replay Protected Monotonic Counters (RPMC)
url: https://www.emergentmind.com/topics/replay-protected-monotonic-counters-rpmcs
type: topic
---

# Replay Protected Monotonic Counters (RPMC)

Replay Protected Monotonic Counters (RPMCs) are hardware-backed mechanisms intended to provide freshness and rollback resistance for persistent state. An RPMC maintains a counter that advances monotonically and authenticates counter operations, allowing a verifier to reject an otherwise valid but stale snapshot. RPMC-like primitives also serve as authenticated, non-equivocating sequence generators in Byzantine fault-tolerant protocols. Their security depends not only on cryptographic authentication but also on rollback-resistant state, correct controller verification, secure key management, and reliable implementation in the hardware and firmware surrounding the counter.

## 1. Definition and security purpose

The central security problem addressed by an RPMC is replay of an earlier authenticated state. Encryption and integrity protection can establish that a stored record was produced by an authorized device, but they do not necessarily establish that it is the newest record. An attacker who restores an older ciphertext together with a valid authentication tag may therefore cause a system to accept stale state.

An RPMC associates protected state with a monotonically increasing value. A simplified freshness relation is:

$$
c_{\mathrm{after\ recovery}} \ge c_{\mathrm{before\ failure}}.
$$

A system can reject a record whose associated counter value is lower than the value previously exposed to correct components. In secure-storage applications, the protected object is typically an encrypted non-volatile record. In protocol applications, the protected object may instead be a request, ordering certificate, or sequence position.

An RPMC generally requires the following security properties:

- **Monotonicity**: successful updates produce increasing counter values.
- **Binding**: a counter value is associated with a particular message, object, or state transition.
- **Authentication**: counter values and associated metadata can be verified as originating from an approved trusted component.
- **Non-equivocation**: one counter instance cannot legitimately authenticate two conflicting messages under the same counter value.
- **Rollback resistance**: a previously exposed counter state cannot be replaced by an earlier state that remains acceptable.
- **Instance separation**: counter states belonging to different epochs, views, or instances are distinguishable.

These properties are distinct. A counter may be cryptographically authenticated yet fail to provide freshness if its state can be rolled back. Conversely, a monotonic counter that is not authenticated may be vulnerable to forged values.

The term RPMC is also used for mechanisms standardized by JEDEC in JESD260. The deployed flash-based design resembles RPMB mechanisms used with eMMC and adds security commands to SPI flash using HMAC-SHA-256 authentication.

## 2. Interfaces and authenticated counter operation

The trusted-counter model used in “Making Speculative BFT Resilient with Trusted Monotonic Counters” is narrower than a general secure-storage RPMC API [1905.10255]. It provides initialization and authenticated increment-and-bind operations.

Initialization creates a counter instance with value zero and an associated public key:

$$
c=0.
$$

An increment operation advances the counter and binds a message $m$ to the new value:

$$
c\leftarrow c+1.
$$

A protocol-level abstraction for this operation is:

$$
\textsf{Next}(m)\rightarrow
\langle \mathrm{instance},c,H(m),\sigma_{\mathrm{TC}}\rangle.
$$

The resulting certificate contains, at minimum, the counter-instance identity or public key, a fresh counter value, the hash of the bound message, and an authenticating signature or attestation from the trusted counter.

The protocol paper does not define a complete RPMC-style interface with independent `Read`, arbitrary `Update(new_value)`, authenticated read proofs, namespaces, labels, comparison proofs, or general crash-recovery semantics. Its relevant read operation is implicit: replicas inspect and verify the value carried by an ordering certificate and check that it follows the preceding value.

A generalized secure-storage interface could expose:

$$
\textsf{Read}()\rightarrow\langle c,\pi_c\rangle,
$$

where $\pi_c$ proves that $c$ is the current non-rollbackable state. Such an interface would also need recovery rules preventing a restored device from accepting a state lower than the greatest state previously exposed to correct replicas.

Flash-based RPMCs use a persistent Root Key and a derived HMAC session key. The session key is derived from controller-provided `Key Data`:

$$
K_{\mathrm{HMAC}}
=
\operatorname{HMAC\mbox{-}SHA256}(K_{\mathrm{Root}},\mathrm{KeyData}).
$$

Relevant operations include writing the Root Key, updating the HMAC key, incrementing the monotonic counter, requesting the counter value, and reading extended command status. A valid increment is intended to verify the expected current value and then perform:

$$
C_{\mathrm{flash}}\leftarrow C_{\mathrm{flash}}+1.
$$

A counter request includes a randomization tag. The response returns the tag, counter value, and a MAC or signature. The controller is expected to verify the response and confirm that the counter has advanced as required.

## 3. RPMCs in Byzantine fault-tolerant protocols

SACZyzzyva uses a trusted monotonic counter to make a primary’s ordering canonical within a view [1905.10255]. The system contains $n=3f+1$ replicas and tolerates up to $f$ faulty replicas. At least $f+1$ replicas possess trusted counters, although only one counter is active in a given view.

The primary invokes the active counter on the hash of each client request:

$$
C_{\mathrm{order}}
\leftarrow
\textsf{TC}_v.\textsf{Increment}\bigl(H(m_{\mathrm{request}})\bigr).
$$

It then broadcasts an order request containing the counter certificate. Replicas accept the request only if the primary signature and counter certificate are valid, the counter belongs to the designated view, the counter value is sequential, preceding values are available, and the request has not already been executed according to the client identifier.

The counter addresses primary equivocation. Without such a primitive, a Byzantine primary could send different requests or orderings under the same apparent sequence number. A secure counter cannot legitimately produce two certificates for the same value containing different messages. The request hash therefore binds the authenticated sequence position to a specific request.

A client completes after receiving $2f+1$ matching replies. Since $n=3f+1$, two such quorums intersect in at least $f+1$ replicas, including at least one correct replica. The normal path consists of client-to-primary, primary-to-replica, and replica-to-client communication. SACZyzzyva consequently retains the linear-message pattern associated with speculative BFT rather than the quadratic all-to-all communication of classical BFT protocols.

The counter does not itself provide BFT agreement. Quorums, ordinary signatures, view changes, checkpointing, retransmission, client completion rules, and rollback provide the distributed agreement properties. The counter supplies authenticated, non-equivocating ordering information.

During a view change, the new primary initializes a fresh counter instance. Its public key is included in the authenticated `NEW-VIEW` message, and replicas confirm a common `NEW-VIEW` hash. Certificates from the old instance are not reused as certificates for the new view. This prevents cross-view replay and prevents an old primary from continuing to issue acceptable order certificates.

SACZyzzyva’s safety theorem is a client-visible prefix property:

$$
H_x\sqsubseteq H_y
\quad\text{or}\quad
H_y\sqsubseteq H_x.
$$

Speculative execution may still be rolled back. Counter certificates prevent conflicting authenticated orderings, but they do not make speculative state-machine effects irreversible.

## 4. Persistence, recovery, and trust boundaries

A secure RPMC requires protection against rollback of the counter state itself. The trusted-counter model assumes rollback resistance and persistence, or an equivalent recovery mechanism, while a view is active. A newly initialized instance can be used after a view change, provided certificates from the old instance cannot be confused with certificates from the new one.

SACZyzzyva’s experimental implementation used Intel SGX. Counter state was held in SGX-protected volatile memory, initialized to zero for each view. Loss of that state after a transient fault was treated as a reason to abandon the view and create a new counter instance rather than as an event requiring recovery of the old counter value. This is not equivalent to a storage-grade persistent RPMC that survives arbitrary power loss while preserving the greatest previously exposed value.

The trusted component is not assumed to be fully Byzantine. Its software host may be Byzantine, and the component may crash or become unavailable, but the protected counter logic is assumed not to generate invalid certificates or allow arbitrary modification of protected state. A counter-equipped replica can therefore suppress valid certificates or refuse to participate; the counter constrains only the certificates that actually exist.

The distinction between software and trusted hardware is essential. A counter does not ensure that the primary sends an ordering certificate, that all replicas receive it, that a request is eventually ordered, or that a client receives a response. Those properties require the surrounding BFT protocol and its synchrony, quorum, recovery, and retransmission assumptions.

In SACZyzzyva, an unavailable counter at the current primary prevents that primary from ordering requests. Eventual progress depends on view changes and a primary-selection rule that eventually selects a correct counter-equipped replica. Under eventual synchrony, a stable view with a correct primary allows the client to obtain $2f+1$ replies.

## 5. Fault thresholds and counter placement

Trusted counters do not automatically reduce the classical $3f+1$ replica requirement. The protocol paper establishes that any consensus protocol tolerating $f$ failures must satisfy at least one of:

$$
n\ge 3f+1
$$

or

$$
n-b\ge 2f+1,
$$

where $b$ is the number of parties that may fail fully Byzantine and $n-b$ is the number whose failures are limited to crash or partial Byzantine behavior.

The underlying condition is quorum intersection. Any two decision quorums must intersect in at least one replica that cannot fail fully Byzantine. Otherwise, the intersection can equivocate between two otherwise isolated quorums and cause conflicting decisions.

If fewer than $2f+1$ replicas have trusted or otherwise non-fully-Byzantine behavior, the system still requires at least $3f+1$ total replicas. In particular, with $n=3f+1$, trusted components must be present in more than two-thirds of replicas to improve the fault threshold.

SACZyzzyva uses only $f+1$ counter-equipped replicas. This is sufficient to ensure that at least one counter-equipped replica is correct when at most $f$ replicas are faulty and to provide a possible sequence of counter-equipped primaries. It is not sufficient to reduce the total population below $3f+1$.

The design therefore improves robustness to slow replicas and removes the non-speculative fallback associated with classical Zyzzyva, but it does not improve the Byzantine fault ratio. This differs from systems such as MinBFT and MinZyzzyva, in which every replica has trusted counter hardware and uses it to authenticate its own non-equivocating messages.

## 6. Flash-based RPMCs and implementation failures

“Hello Again: Exploiting Replay Protected Monotonic Counters to Brute-Force Windows Hello PINs” analyzes RPMCs used to protect firmware TPM non-volatile state on shipping x86 systems [2611.18126]. The relevant state includes failed-PIN and lockout counters. If an attacker restores an earlier SPI-flash image, the fTPM may also restore an earlier anti-hammering state, causing failed authentication attempts to disappear.

The intended chain is:

$$
\text{fTPM state change}
\longrightarrow
\text{NV state update}
\longrightarrow
\text{RPMC increment}
\longrightarrow
\text{freshness check on next boot}.
$$

The study found failures at multiple layers:

- **Winbond HMAC-key leakage**: voltage glitching could expose the HMAC session key, enabling arbitrary counter-response forgery.
- **AMD unverified increments**: the AMD NV controller did not verify that an RPMC increment actually occurred. An interposer could suppress the increment and fabricate a successful status.
- **AMD fallback weakness**: two tested AMD systems without RPMC-capable flash accepted old SPI images and restored earlier fTPM lockout state.
- **Intel session-key reuse**: Intel repeatedly used `KeyData = 0x1` across boots, causing the same HMAC session key to be regenerated for a given counter. This did not independently enable forgery but made a Winbond key-leak attack persistent across boots.
- **Counter overflow**: tested chips used 32-bit counters that wrapped from $2^{32}-1$ to zero.
- **GigaDevice corruption**: voltage glitching could cause a signed response to contain an incorrect counter value.

The AMD controller failure can be expressed as the difference between the intended and observed workflows. A correct controller should perform:

$$
\operatorname{Increment}(C)
\rightarrow
\operatorname{Request}(C)
\rightarrow
\operatorname{VerifySignature}(\mathrm{Tag},C+1).
$$

The observed behavior was effectively:

$$
\operatorname{Increment}(C)
\rightarrow
\operatorname{AssumeSuccess}.
$$

The attacks require prolonged physical access to the motherboard and SPI flash bus. They do not require remote network access, compromise of Windows, compromise of the fTPM execution environment, knowledge of the PIN, direct decryption of flash contents, or extraction of TPM secrets. The attacker manipulates the freshness mechanism surrounding encrypted state.

The end-to-end consequences were demonstrated on locked and encrypted systems. A four-digit Windows Hello PIN was recovered at approximately 4.14 attempts per minute, reducing the reported worst-case time from 69 days to 40 hours. A default-length six-digit BitLocker TPM+PIN credential was recovered at approximately 34.1 attempts per minute, reducing the reported worst-case time from 19 years to 20 days.

These results do not show that RPMCs are intrinsically incapable of providing rollback protection. They show that encryption and integrity protection of non-volatile records are insufficient when the monotonicity mechanism can be forged, suppressed, corrupted, or rolled back.

## 7. Applications, limitations, and mitigations

RPMC-like mechanisms apply to persistent storage freshness, firmware and version ratchets, fTPM state, anti-hammering counters, encrypted-device unlock, and authenticated protocol ordering. Their application to BFT protocols demonstrates that one active authenticated counter can provide a canonical ordering primitive without installing active counter hardware at every replica. Their application to fTPM storage demonstrates that the same primitive can become a platform-wide security dependency.

Several limitations recur across deployments. A volatile trusted counter is not a persistent RPMC. A counter without publicly verifiable authentication cannot safely support distributed agreement. A counter that is authenticated but not checked by the controller does not provide effective freshness. A counter with ambiguous maximum-value behavior may wrap and accept lower values. Finally, speculative protocol execution may still require rollback even when its ordering certificates are secure.

Mitigations described for flash-based deployments include hardware revision of vulnerable Winbond parts, elimination of externally readable HMAC-output registers, robust clearing of internal secret registers, fault-injection detection, and glitch-resistant counter operations. AMD can verify increments by requesting and authenticating the resulting counter value, while also preventing downgrade to vulnerable firmware. Intel can generate fresh unpredictable `KeyData` for every HMAC-key update and may use its pre-RPMC rollback mechanism on systems with vulnerable flash. JEDEC can clarify maximum-counter behavior by requiring saturation or rejection at $2^{32}-1$.

At the policy layer, longer Windows Hello and BitLocker PINs increase brute-force time but do not repair RPMC rollback. The cited work recommends six or more digits for Windows Hello and eight or more digits for BitLocker TPM+PIN configurations. More generally, robust deployment requires secure counter state, authenticated and verified updates, explicit instance or epoch separation, recovery protection, and a surrounding protocol or storage system that treats counter output as one component of freshness rather than as a complete agreement or authorization mechanism.

Source: https://www.emergentmind.com/topics/replay-protected-monotonic-counters-rpmcs