Repository navigation
feat(audit): tamper-evident hash-chained audit log + kit audit verify - #86
Merged
Merged
Conversation
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
|
✅ Docker image built successfully
|
This was referenced Jun 23, 2026
`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>
|
✅ Docker image built successfully
|
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.
No-egress roadmap (#80): tamper-evident audit trail.
The audit log was plain JSONL — entries could be altered/deleted/reordered undetectably. Now hash-chained:
prev(previous hash) +hash(sha256 over the canonical pre-hash JSON). Both append paths use it.verifyAuditChain()(pure, tested) reports the first break — content tamper (hash mismatch) or insert/delete/reorder (prev-link mismatch) — with index.kit audit verifysurfaces it (green intact / red BROKEN at N).Full suite: 1448 pass / 0 fail (audit format gained
prev/hash; consumers read by field, unaffected). Cross-process concurrent appends can fork the chain (external tampering still detected); syslog/CEF export is a follow-up. Independent of the air-gap stack (#73/#83/#84/#85).Generated by Claude Code