OGOPSEC // Dispatch
Anti-Rollback and Wipe-After-N: TPM Monotonic Counters
Encryption keeps data confidential. It does not, by itself, stop someone from rewinding your system to an earlier, more convenient state — an old database with a since-revoked token still valid, a counter reset so a guessing attack starts fresh, a backup restored to undo a lockout. This is the replay, or rollback, problem, and it is where TPM anti-rollback earns its place. The tool is unglamorous: a counter that only ever goes up.
A monotonic counter is a value in the TPM's non-volatile memory that can be incremented but never decremented or reset, even by the machine's owner. That one property turns out to be the foundation for two valuable protections: rejecting stale state, and enforcing a hard limit on failed attempts.
The mechanism: a number that cannot go backward
You define an NV index configured as a counter, then increment it at meaningful moments. The current value becomes a timestamp that no amount of disk restoration can forge downward.
# Define a monotonic counter in TPM NV storage
sudo tpm2_nvdefine -C o 0x1500016 -a "nt=counter|ownerwrite|ownerread"
# Increment it
sudo tpm2_nvincrement 0x1500016
# Read the current value
sudo tpm2_nvread 0x1500016 | xxd
Try as you might, you cannot make that index report a lower number than it has already reached. Restoring an old disk image does not help, because the counter lives in the chip, not on the disk.
Anti-rollback: refusing stale state
To use the counter for rollback protection, you bind a protected secret or sealed blob to a specific counter value. When state advances — a credential is rotated, a session is revoked — you increment the counter and reseal against the new value. If an attacker later restores an older copy of the encrypted state, the counter in the chip is now higher than the value the old blob expects, and the TPM refuses to release the secret. The stale state is cryptographically dead.
This is how you defeat the "just restore the backup" move. The backup still exists, but the chip knows it is behind and will not cooperate.
Wipe-after-N: a hard ceiling on guessing
The same counting idea enforces a maximum number of failed authorizations. Each failed attempt increments a failure counter; a policy ties the credential to that counter staying below a threshold. Cross the threshold and the secret becomes permanently unusable — the key material it protected is effectively wiped, because the TPM will never release it again.
- The count is kept in hardware, so an attacker cannot reset it by restoring state or rebooting.
- Combined with the TPM's built-in dictionary-attack lockout, this makes brute force a game you lose quickly and permanently.
- It converts "unlimited offline guesses" into "N tries, then the data is gone."
Wipe-after-N is deliberately unforgiving. Its value comes from being irreversible, which means your enrollment and recovery design has to assume a wipe can happen — to you, by accident — and plan for re-provisioning rather than rescue.
What anti-rollback does not do
Monotonic counters are precise and narrow. They do not encrypt anything on their own; they gate the release of secrets other mechanisms protect. They do not notice tampering that happens without touching the counter-bound secret. They cannot protect against an attacker who compromises the running system and advances or uses state legitimately through your own software. And NV counter space is finite and has endurance limits, so you increment on meaningful events, not in a tight loop. As always, a firmware TPM shares its trust boundary with the CPU and is weaker against determined physical attack than a discrete chip.
Where it belongs in a design
Anti-rollback and wipe-after-N are not features you ship alone; they are reinforcements under a credential or vault system. They answer two specific questions — "is this the current state?" and "have too many attempts failed?" — and they answer them in hardware, where restoring a disk image cannot lie. In Dire Wolf we use TPM monotonic counters for exactly these roles: anti-rollback so a revoked credential cannot be resurrected from an old image, and a wipe-after-N ceiling so a lost device cannot be ground down by patient guessing. We also say plainly that these are bounded protections against replay and brute force — not a cure for a compromised live system. That honesty is the point: a counter that only goes up is powerful precisely because it does one thing and does it without exception.