Repository navigation
fix(governance): fail-closed audit for destructive ops (F2) - #88
Merged
sandstream merged 1 commit intoJun 24, 2026
Merged
Conversation
`withGovernance`'s allow-path was fail-OPEN on audit logging: a destructive op ran (and its success was logged AFTER execution), so if the audit append failed the op still executed — unlogged. Only the deny paths failed closed, despite the "fails closed" framing. - `logAuditEvent` now returns a boolean (true when the local append succeeded, true when audit is disabled, false on write failure). Backward-compatible — existing callers ignore it. - `withGovernance` now persists an "authorized" audit entry BEFORE executing a `context.destructive` op and refuses (throws fail-closed) if it can't be written. Non-destructive ops keep best-effort logging. Tests cover logAuditEvent's return (success / unwritable path / disabled). Full suite 1451/0. Stacked on the audit hash-chain branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
Closed
3 of 4 tasks
sandstream
added a commit
that referenced
this pull request
Jun 24, 2026
…#86) * feat(audit): tamper-evident hash-chained audit log + `kit audit verify` The audit log was a plain JSONL append — an attacker (or a careless edit) could alter, delete, or reorder entries undetectably. For a regulated/air-gapped enclave the audit trail must be tamper-evident. - Each appended line now carries `prev` (previous line's hash) and `hash` (sha256 over the line's canonical pre-hash JSON), forming a hash chain. Both append paths (`appendAuditEventDirect`, `logAuditEvent`) use it. - `verifyAuditChain()` (pure, exported) re-walks the chain and reports the first break: content tamper (hash mismatch) or insertion/deletion/reorder (prev-link mismatch), with the 0-based index. - `kit audit verify` surfaces it on the CLI (green intact / red BROKEN at N). Tests cover a verified chain, tampered content, a deleted entry, and a legacy unchained entry. Note: cross-process concurrent appends can fork the chain; external tampering is still detected. Syslog/CEF export for SIEM is a follow-up. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg * fix(governance): fail-closed audit for destructive ops (#81 F2) (#88) `withGovernance`'s allow-path was fail-OPEN on audit logging: a destructive op ran (and its success was logged AFTER execution), so if the audit append failed the op still executed — unlogged. Only the deny paths failed closed, despite the "fails closed" framing. - `logAuditEvent` now returns a boolean (true when the local append succeeded, true when audit is disabled, false on write failure). Backward-compatible — existing callers ignore it. - `withGovernance` now persists an "authorized" audit entry BEFORE executing a `context.destructive` op and refuses (throws fail-closed) if it can't be written. Non-destructive ops keep best-effort logging. Tests cover logAuditEvent's return (success / unwritable path / disabled). Full suite 1451/0. Stacked on the audit hash-chain branch. Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg Co-authored-by: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the F2 finding (#81):
withGovernance's allow-path was fail-OPEN on audit logging — a destructive op ran (success logged only AFTER execution), so a failed audit append left the op executed-but-unlogged. Only deny paths failed closed, despite the "fails closed" framing.logAuditEventnow returns a boolean (true on local-append success, true when audit disabled, false on write failure). Backward-compatible — existing callers ignore it.withGovernancepersists an "authorized" audit entry before executing acontext.destructiveop and refuses (throws fail-closed) if it can't be written. Non-destructive ops keep best-effort logging.Tests cover logAuditEvent's return (success / unwritable / disabled). Full suite 1451/0.
feat/audit-tamper-evident).Generated by Claude Code