A local encrypted container is often described as a locked box. That metaphor hides an important failure mode: an attacker does not have to open the box. They can replace it with yesterday’s box.
DefNote addresses that with an authenticated header. The header carries a vault ID, an epoch counter and a state token, and it is bound to the encrypted payload. A container file that has been swapped or rolled back does not verify, so the app rejects it instead of silently restoring stale records.
The attack encryption alone does not stop
AES-256-GCM is an authenticated cipher: it detects changes to the ciphertext. If an attacker flips a byte, decryption fails. But if they replace the whole file with an older, validly encrypted copy, every byte still authenticates. The cipher is doing its job; the problem is that it has no memory of which ciphertext is current.
This is the rollback problem, and it is especially relevant on a device where files can be copied, restored from an old backup or replaced by a second installation. The consequence is not a crash. It is a vault that opens with records you thought you had deleted.
What goes into the authenticated header
- Vault ID — identifies the container as this vault, not another one from the same app.
- Epoch counter — advances as the vault changes, so an older container is distinguishable from the current one.
- State token — a value tied to the vault’s state, so a file cannot be silently substituted or replayed.
- Binding — the header is authenticated together with the payload, so the fields cannot be edited independently of the ciphertext.
The exact encoding is an implementation detail. The property is not: the identity and age of the container are part of what the key authenticates. Without that, a valid old file is indistinguishable from a valid current one.
Why an epoch counter
An epoch counter is a monotonic number that advances whenever the vault’s state changes. It gives the app a cheap way to answer a question the ciphertext cannot: is this the newest container I have written, or an older one presented as current?
The counter does not need to be secret. It needs to be authenticated. If an attacker can change the counter and the change still verifies, the protection is decorative. Binding the counter into the authenticated header means a mismatch is a verification failure, not a value to trust.
The same logic applies to the vault ID and state token. The ID prevents a container from being swapped for another vault’s file; the state token prevents a valid header from being replayed against different contents. Together they turn “the file decrypts” into “the file is the current state of this vault”.
What the check does and does not prove
Because DefNote has no server and no sync, there is nowhere to ask “what is the latest version?” The answer has to live on the device, inside the container’s authenticated metadata. That makes the check self-contained, and it makes the device the final authority — which is the same property that makes the vault offline in the first place.
Designing the property into an iOS vault
- Authenticate metadata, not just payload. Put identity and age fields inside the same authenticated envelope as the ciphertext.
- Treat verification failure as terminal. Do not attempt an automatic repair, fallback or “best effort” open when the header does not match.
- Persist the counter with care. A counter that can be silently rewound is not a counter; it is a suggestion.
- Keep the key out of the container. A device-only Keychain item that is not synced, backed up or exported cannot travel with a copied file.
- Document the failure modes. Users should know that a rejected container is a security decision, not a bug.
These are ordinary engineering disciplines, but they are easy to skip when the happy path works. A vault that opens the current file on the developer’s phone has not demonstrated that it rejects the previous one.
What to look for in a local vault
- Does the documentation state which fields are authenticated, or only which cipher is used?
- Is the key device-bound, and is it explicitly not synced or exported?
- Does the app explain what happens when a container fails verification?
- Are the limits — no recovery, no sync, no autofill — stated as clearly as the features?
DefNote is not open source, but its cryptography is documented: AES-256-GCM, a device-only Keychain key, PBKDF2-HMAC-SHA256 with 210,000 iterations and an authenticated header. It requires iOS 17 or later and runs on iPhone and iPad. The app is free to try for 30 days of writing; DefNote Pro is a one-time US$1.99 purchase with no subscription.
Questions people ask
- What is a rollback attack on a local encrypted file?
- It replaces the current encrypted container with an older but validly encrypted copy. Encryption still verifies, yet the app opens stale records. DefNote's authenticated epoch counter and state token are designed to reject that.
- How does an authenticated header work with AES-256-GCM?
- The header fields are bound into the authenticated data, so changing the vault ID, epoch counter or state token invalidates verification rather than producing a decryptable container.
- Does DefNote verify the container against a server?
- No. There is no server and no sync. The current-state information lives on the device inside the authenticated container, and the app rejects a file that does not match.
- Can tamper detection recover a damaged vault?
- No. Verification failure is treated as a security outcome. There is no automatic repair and no recovery if the passcode is forgotten.
