Definition
A version high-water mark is a number kept in persistent storage that records the highest version a device has committed to so far, meaning adopted as its new baseline, and that never decreases. The device compares the version of every candidate, such as a firmware image or a numbered command, with the mark and refuses a candidate that is older. The mark is stored apart from the version currently running, because the running version may legitimately go down after a failed update while the mark must not.
The idea
A device that refuses old software needs to remember what “old” means. The version it is running is the wrong reference. After a new version fails its trial, the device goes back to the previous one, and the running version falls; if old meant “older than what runs”, the meaning would fall with it. The device needs a separate record that only moves up.
The same need arises for messages. A receiver that must refuse a replay attack §1.26, in which a recorded genuine message is sent again, could store every nonce §5.18, a value meant to be used only once, that it has ever accepted, and refuse any nonce it has seen. That list grows without limit. If instead every message carries a number larger than the one before, the receiver needs to store one number: the highest it has accepted. Every earlier message carries a number no larger than that, so all of them are refused at once.
The name comes from the mark that a flood leaves on a wall at the highest level the water reached. The water falls again, but the mark stays and shows how high the water once rose. The picture stops at two points. A visitor cannot wipe off a flood mark, whereas a number in flash memory §6.6 can be rewritten by anyone who can write that flash. And the water decides its own level, whereas the device must decide which event counts as reaching a version: receiving it, installing it or confirming that it works.
How it works
The device keeps one number , the mark, in persistent storage. At manufacture is set to the version installed at the factory, or to 0. Each candidate carries a version inside the bytes that its digital signature §5.14 or message authentication code §5.7 (MAC) covers, so an attacker cannot change without the check failing.
Acceptance rules. Four rules are in use, and they give different guarantees.
At least as new: accept when . The current version can be accepted again, which lets a device reinstall its current image to repair a damaged copy. The most recent accepted command can also be accepted again, so this rule does not refuse every replay.
Strictly newer: accept when . Every candidate ever committed had a version of at most , so every one of them is refused. Gaps are allowed: a sender may go from 5 straight to 1000.
Exact successor: accept only when . Every earlier candidate is refused, as under the strictly newer rule, and in addition no value can be skipped, so the mark rises by exactly one per accepted candidate. The sender must know , and a candidate that is lost stops the sequence until it is sent again.
Expected-state guard: the candidate names the state it expects to replace, for example “replace key epoch 4 by key epoch 5”, and the device acts only if its current state is the named one. This is a compare-and-swap §9.9 on stored state: compare the current state with the expected one, and change it only if the two are equal. It can bind a request to a particular key or configuration, not only to a number. The State transition guard §8.34 entry treats guards in general.
Advancing the mark. When a candidate is committed, the device sets to the larger of and ; under the exact-successor rule this is simply . The order of this write relative to the candidate’s own effect decides what a crash does.
Mark first, effect second. A crash between the two leaves the mark raised but the effect missing. The same candidate is now refused as not newer, so the update is lost and the sender must issue a new version. For a firmware floor, the result can be a device that refuses its only working image, as the Rollback versus anti-rollback §8.26 entry shows.
Effect first, mark second. A crash between the two leaves the effect applied but the mark old. The same candidate is then accepted once more, so applying it twice must be harmless, the property called idempotency §8.31.
Both in one commit. The record that makes the effect current also holds the new mark, and that record is written atomically, so the two change together. This is the safe choice whenever the storage layout allows it.
Storing the mark. A power failure can leave a single location in flash memory half-written, which is called a torn write §8.19. A common layout keeps two copies, each with a sequence number and a checksum §4.32; the writer overwrites the older copy, and the reader takes the newer copy whose checksum is correct. If neither copy is readable, the device must fail closed §1.13: refuse every candidate and wait for recovery, and never fall back to a default of 0, which would accept every version. Flash memory tolerates only a limited number of erase cycles, so a mark that changes with every message is written as new records appended to a region, not by erasing one location each time.
Protecting the mark. An attacker who can rewrite the storage can lower . Hardware that cannot count down, such as one-time programmable (OTP) fuses or a separate security chip, can hold the mark itself, or a reference copy against which the stored mark is checked at every start. The Monotonic counter §8.28 entry describes these options and what each resists. Systems use their own names for the mark: Android Verified Boot keeps a stored rollback index, and MCUboot, an open-source bootloader §6.30 for microcontrollers §6.1, compares a security counter carried in each signed image with a value kept in protected storage.
Worked example
Refusing an old image. The mark starts at . Version 9 arrives with a valid signature and is committed, so becomes the larger of 7 and 9, which is 9. Later, version 8 arrives, also with a valid signature. Under the at-least-as-new rule it is refused, because . The signature on version 8 is genuine; only the mark stops it.
Resetting the mark. An attacker saved a copy of the whole flash memory while was 7 and now writes that copy back. The device reads , and version 8 now passes, because . Nothing about the image or its signature changed; only the stored mark did. The restored bytes are exactly bytes the device once wrote itself, so no check of their format or checksum can detect the change.
Corrupting the mark. Power fails while the only copy of is being rewritten, and its checksum no longer matches. Code that treats an unreadable mark as 0 then accepts version 1, the oldest of all. Code that fails closed accepts nothing until the mark is restored from a protected copy.
Comparing the rules. Let , and let candidates numbered 41, 42 and 45 each be checked against it:
| candidate | |||
|---|---|---|---|
| 41 | accepted | refused | refused |
| 42 | accepted | accepted | accepted |
| 45 | accepted | accepted | refused |
Number 41 was already committed, so it is a replay, and only the at-least-as-new rule lets it through. Number 45 skips 42, 43 and 44, which only the exact-successor rule refuses.
Running out of numbers. Let be a 32-bit unsigned number, so its largest value is . Under the strictly newer rule, one authorized candidate with sets to that value, and from then on no 32-bit is larger, so the device can never accept anything again. Under the exact-successor rule the mark rises by one per accepted candidate. At one candidate per second, reaching the top takes about seconds, and years, where is the number of seconds in a year of 365.25 days.
At the top, a careless check is dangerous. In unsigned modular arithmetic §4.16 on 32 bits, at wraps around to 0, so a check written as “accept if ” accepts , and every old candidate becomes acceptable again. Correct code first tests whether has reached its largest value and refuses if so, or computes in a wider type.
Stated precisely
Let the mark be an unsigned number of bits, so , and let be the version carried inside the authenticated bytes of a candidate. The three numeric rules accept a candidate when, respectively, When a candidate is committed, the new mark is , the larger of the old mark and the candidate’s version.
As arithmetic, the update never lowers the mark: for every . Under the strictly newer and exact-successor rules, no candidate whose version has ever been committed is accepted again, because each such version is at most the current . The stored value follows this arithmetic only under five assumptions.
The version is authenticated together with the candidate.
The commit is the only operation that writes .
The write of is atomic with the commit of the candidate’s effect, or the effect is idempotent.
Nothing in the threat model §1.2, the written account of what an attacker and the environment can do, can restore or reprogram to an older value.
The comparison and the computation of do not wrap around.
Limits and common mistakes
A checksum or a cyclic redundancy check (CRC) detects accidental damage to the stored mark, not its replacement by an older record that has a correct checksum. A message authentication code computed with a key held only by the device detects a forged record, but not an older genuine record written back. Only a reference that itself cannot be set back, as described in the Monotonic counter entry, detects that.
The mark is not authentication §1.6. It refuses old candidates and does nothing against a new one that an attacker made; that is the job of the signature check, which must cover the version number.
Each kind of object that must not go backwards, such as firmware, configuration and key sets, needs its own mark. One shared mark lets a high version of one kind block every other kind. Two senders that number their messages independently also need separate marks.
Version formats need an exact comparison rule. Compared character by character as text, the version string 1.10 sorts before 1.9, because their third characters are 1 and 9, and 1 sorts first. Versions are compared as numbers of fixed width, or as tuples compared one component at a time from the most significant component.
If a new signing key restarts version numbering at 0, the mark refuses the new key’s first images. If the mark is reset for the new key, old images signed with the old key must be refused by key revocation §5.32 instead. A common approach compares a pair of numbers §19.3.3: the sequence number of the signing key first, then the version.
Exhaustion is a denial of service §1.28: once the mark is at its largest value, nothing more can be accepted. The exact-successor rule limits how fast the mark can be driven there; the strictly newer rule does not.
Questions answered
Can an attacker reset, corrupt, or replace the high-water state?
Yes. An attacker can reset, corrupt or replace a version high-water mark whenever the attacker can write the storage that holds it, and a location in ordinary flash memory gives no protection by itself. The high-water mark is the stored record of the highest version the device has committed to; the device refuses any candidate older than it, so lowering it reopens every old version.
Reset: an attacker with physical access erases and reprograms the flash, or writes back a saved copy from a time when the mark was lower. A software flaw that lets an attacker write flash has the same effect.
Corrupt: a power failure during a write, a fault in the storage or a deliberate glitch leaves an unreadable mark. If the code then assumes 0, every version is accepted.
Replace: an older genuine record is written back. A checksum, and even a message authentication code (MAC) keyed with a device secret, accepts it, because the device wrote exactly those bytes once.
The defenses match the three cases. Keep the mark, or a reference copy of it, in storage that cannot count down, such as one-time programmable (OTP) fuses or a separate security chip, and refuse to start when the stored mark is below that reference. Write the mark crash-safely, for example as two copies with sequence numbers and checksums, and fail closed when no copy is valid. Commit the mark together with the effect it records. Whatever the design, its threat model must say which of these attacks it covers: a device whose whole storage an attacker can restore cannot detect the restoration from the restored bytes alone.
Related entries: Rollback versus anti-rollback (§8.26), Monotonic counter (§8.28), Crash consistency (§8.4), Recovery key (§5.31), Replay attack (§1.26), Counter wraparound (§6.21), State transition guard (§8.34), Lexicographic version order versus componentwise order (§19.3.3), Idempotency (§8.31). Further reading: [21].