Repository navigation
docs(runbook): the audit database was recreated or restored (#3772 slice 5) #3894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8c7170e
4239adb
0245671
ba94683
9f3930a
609b222
ab72304
54fceb5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - **Runbook: "The audit database was recreated or restored"** (#3772). Step by step recovery with `containarium audit anchor new-epoch`, what it writes, what `audit verify-anchor` shows afterwards, and what the recovery does not protect against. The "daemon refuses to anchor" section now describes startup detection. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1525,17 +1525,109 @@ acting on it: | |||||||||||||||||
| history, and editing it is exactly what the refusal guards against. | ||||||||||||||||||
|
|
||||||||||||||||||
| Anchoring resumes on its own once the chain passes the last anchored | ||||||||||||||||||
| checkpoint. A recorded recovery that starts a new anchor epoch, so that | ||||||||||||||||||
| `verify-anchor` treats the break as a documented break and not as | ||||||||||||||||||
| tampering, is tracked in #3549. The state is held in memory, so after a | ||||||||||||||||||
| daemon restart the signals above reappear at the first refused tick, within | ||||||||||||||||||
| one anchor interval (`CONTAINARIUM_AUDIT_ANCHOR_INTERVAL`, 15 minutes by | ||||||||||||||||||
| default), not at startup. A conflict (a checkpoint already anchored with a | ||||||||||||||||||
| different root) that persists across ticks is not the "database recreated" | ||||||||||||||||||
| case: run `containarium audit verify-anchor` and treat a mismatch as a | ||||||||||||||||||
| possible rewrite. A single conflict that clears on the next tick can happen | ||||||||||||||||||
| when a recreated chain lands exactly on the last anchored checkpoint while | ||||||||||||||||||
| it climbs past it. | ||||||||||||||||||
| checkpoint. If the database was recreated or restored on purpose, do not | ||||||||||||||||||
| wait for that: record the break with the steps in | ||||||||||||||||||
| [The audit database was recreated or restored](#the-audit-database-was-recreated-or-restored). | ||||||||||||||||||
|
|
||||||||||||||||||
| A chain that is already behind the anchor when the daemon starts is | ||||||||||||||||||
| reported at startup (`DEGRADED (found at startup)` in the daemon log, and | ||||||||||||||||||
| the readiness entry goes NOT_SERVING at once), not after the first anchor | ||||||||||||||||||
| interval (`CONTAINARIUM_AUDIT_ANCHOR_INTERVAL`, 15 minutes by default). The | ||||||||||||||||||
| state is held in memory, so a restart reports it again. A conflict (a | ||||||||||||||||||
| checkpoint already anchored with a different root) that persists across | ||||||||||||||||||
| ticks is not the "database recreated" case: run | ||||||||||||||||||
| `containarium audit verify-anchor` and treat a mismatch as a possible | ||||||||||||||||||
| rewrite. A single conflict that clears on the next tick can happen when a | ||||||||||||||||||
| recreated chain lands exactly on the last anchored checkpoint while it | ||||||||||||||||||
| climbs past it. | ||||||||||||||||||
|
|
||||||||||||||||||
| ### The audit database was recreated or restored | ||||||||||||||||||
|
|
||||||||||||||||||
| Use this when the platform Postgres was recreated, or restored from an older | ||||||||||||||||||
| copy, you have confirmed that is what happened (see the checks above), and the | ||||||||||||||||||
| daemon refuses to anchor the new chain. `new-epoch` does not reset the anchor. | ||||||||||||||||||
| It ends the old anchor history on the record and starts a new one, and | ||||||||||||||||||
| `verify-anchor` shows the break. | ||||||||||||||||||
|
|
||||||||||||||||||
| 1. **Stop anchoring.** Stop the daemon, or run the command while it is | ||||||||||||||||||
| refusing. A publish that lands while the command works makes it abort and | ||||||||||||||||||
| change nothing. | ||||||||||||||||||
|
|
||||||||||||||||||
| 2. **Start the new epoch**, as root, with a reason and the confirmation flag: | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| sudo containarium audit anchor new-epoch \ | ||||||||||||||||||
| --reason "audit database restored from the <date> backup" \ | ||||||||||||||||||
| --confirm-new-epoch | ||||||||||||||||||
|
Comment on lines
+1559
to
+1561
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Specify the daemon's anchor path. If the daemon uses a non-default anchor path from its service environment, this
|
||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| `--anchor-path` defaults to `CONTAINARIUM_AUDIT_ANCHOR_PATH`, then the | ||||||||||||||||||
| daemon's default. The command refuses, before it touches the file or the | ||||||||||||||||||
| database, when `--confirm-new-epoch` or `--reason` is missing or the caller | ||||||||||||||||||
| is not root. The actor is the user behind `sudo` (`$SUDO_USER`), else the | ||||||||||||||||||
| current user. | ||||||||||||||||||
|
|
||||||||||||||||||
| 3. **What it did.** It prints the archive path, the archive's sha256 and the | ||||||||||||||||||
| last anchor the old file held, and: | ||||||||||||||||||
| - copied the old anchor file, whole, to `<anchor-path>.archived-<UTC time>` | ||||||||||||||||||
| (mode 0600, never over an existing file). The old file is archived, never | ||||||||||||||||||
| deleted: keep the archive, with the rest of your evidence, for as long as | ||||||||||||||||||
| you keep the audit log; | ||||||||||||||||||
| - replaced the anchor file, atomically, with a new one whose first line is | ||||||||||||||||||
| a break record: when, who, why, the archive and its sha256, the last | ||||||||||||||||||
| checkpoint and root, and the epoch number (the first break starts epoch | ||||||||||||||||||
| 2); | ||||||||||||||||||
| - recorded the same in the audit chain, as action | ||||||||||||||||||
| `audit_anchor_new_epoch` (`containarium audit query --action | ||||||||||||||||||
| audit_anchor_new_epoch`). If the database write fails the command says the | ||||||||||||||||||
| file was changed, names the archive and sha256, and the break record in the | ||||||||||||||||||
| file still names the actor. | ||||||||||||||||||
|
|
||||||||||||||||||
| 4. **Start the daemon.** The next tick publishes at the chain's current | ||||||||||||||||||
| checkpoint and anchoring resumes. Rollback protection applies again from | ||||||||||||||||||
| there. | ||||||||||||||||||
|
|
||||||||||||||||||
| With `CONTAINARIUM_AUDIT_ANCHOR_BUCKET` or a timestamp authority configured, | ||||||||||||||||||
| the objects are keyed by checkpoint, and a new epoch restarts at low | ||||||||||||||||||
| checkpoints. Epoch 1 keeps its original names. Epoch *n* after it publishes | ||||||||||||||||||
| under `<prefix>epoch-<n>/` in the bucket and under | ||||||||||||||||||
| `<anchor-path>.tsa/epoch-<n>/` for tokens, so nothing already written moves or | ||||||||||||||||||
| is overwritten. The daemon follows the anchor file's epoch, so a break made | ||||||||||||||||||
| while it runs takes effect on the next publish. | ||||||||||||||||||
|
|
||||||||||||||||||
| #### What `verify-anchor` shows afterwards | ||||||||||||||||||
|
|
||||||||||||||||||
| `containarium audit verify-anchor` prints each recorded break as a break (when, | ||||||||||||||||||
| who, why, the archive and its sha256) and says the archive is present and | ||||||||||||||||||
| unchanged. This is not a failure. It checks, for every break including those | ||||||||||||||||||
| recorded inside archives: | ||||||||||||||||||
|
|
||||||||||||||||||
| | Result | Meaning | Exit | | ||||||||||||||||||
| | --- | --- | --- | | ||||||||||||||||||
| | ⚠ | A recorded break. The archive is present, matches its recorded sha256 and ends at the last anchor the break records. | 0 | | ||||||||||||||||||
| | ✗ | The archive is missing, has changed, or does not end at the anchor the break records. Deleting the old history after a break does not pass as a clean break. | non-zero | | ||||||||||||||||||
| | ✗ | With `--anchor-bucket`: an earlier epoch's bucket prefix holds an object the epoch's archive does not hold, or one with a different root. | non-zero | | ||||||||||||||||||
| | ✗ | With `--anchor-tsa-trust-bundle`: an earlier epoch's token is for a record the archive does not hold, is stamped over a different record, or is not signed by a trusted TSA. | non-zero | | ||||||||||||||||||
| | ⚠ | An earlier epoch's archive holds checkpoints the bucket does not (an upload that never succeeded, or a different prefix). | 0 | | ||||||||||||||||||
| | ✗ | A drop in the anchor with **no** break record. This is the unexplained case and still fails, exactly as before. | non-zero | | ||||||||||||||||||
|
|
||||||||||||||||||
| The current epoch is checked against the database as always. Earlier epochs | ||||||||||||||||||
| are not: their rows are gone with the old database, so they are compared with | ||||||||||||||||||
| their archive, and the archive with the sha256 in the break record. | ||||||||||||||||||
|
|
||||||||||||||||||
| #### What this does not protect against | ||||||||||||||||||
|
|
||||||||||||||||||
| - The break record is written by whoever runs the command as root. It makes | ||||||||||||||||||
| the break visible and attributable; it does not prove the reason is true. | ||||||||||||||||||
| Review `audit_anchor_new_epoch` entries, and the archive, when you audit. | ||||||||||||||||||
| - A host-root attacker can still stop the daemon, run `new-epoch`, and start a | ||||||||||||||||||
| new history. What they cannot do is make it unrecorded: the break record, | ||||||||||||||||||
| the archive with its sha256, the audit entry, and any bucket or timestamp | ||||||||||||||||||
| copy of the earlier epoch remain. Keep an off-host copy of the anchor file | ||||||||||||||||||
|
Comment on lines
+1623
to
+1626
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Local break evidence does not survive a host-root attacker. The limitations paragraph says the break record, archive, and audit entry remain after a host-root attacker runs Suggested wording
Committable suggestion
|
||||||||||||||||||
| and the archives; the bucket copy of the earlier epochs is what a host-root | ||||||||||||||||||
| attacker cannot edit. | ||||||||||||||||||
| - A rollback is not a recovery. If the database was *not* recreated or | ||||||||||||||||||
| restored, do not run this: verify first (`containarium audit verify-anchor`). | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Anchoring to a bucket | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The abort guarantee does not cover a publish during the final install window.
NewEpochchecks for a changed anchor file atinternal/audit/anchor_epoch.go:184, then renames the new file over the live one at line 189. The only lock isf.mu. It serializes calls within one process, andPublishRoottakes the same per-instance lock. The daemon publishes from its own process, so it does not take the command's lock. A publish that appends between the check and the rename is written to the old file. The rename then replaces that file, and the new live file does not contain the publish. The archive was copied earlier and does not contain it either. The command still reports success. The daemon has already recorded that checkpoint as published, so it does not publish it again until new rows arrive.The runbook at
docs/security/OPERATOR-SECURITY-RUNBOOK.md:1552-1554says that a publish during the command makes it abort and change nothing. That is true only for a publish before the check at line 184. The doc comment atinternal/audit/anchor_epoch.go:102-103states the same guarantee for the whole read-to-rename window, and that claim is also too broad.Narrow the runbook text. Do not say the command aborts on any publish during the run. A refusing daemon can also publish once the chain tail passes the anchor, so "run it while refusing" does not prevent the race. Either require the daemon to be stopped before
new-epochruns, or add cross-process locking that is held from the read through the rename. Then state the protection that applies. Correct theNewEpochdoc comment to match.