Add tamper-evident audit log (audit package, logx verify/keygen) - #1
Merged
Conversation
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.
Adds an
auditsubpackage: an append-only, hash-chained, optionally Ed25519-signedslog.Handlerfor tamper-evident logging, pluslogx verifyandlogx keygento check and key it.What
audit.NewHandlerwrites each record as a hash-chained entry.hash = SHA-256(seq, prev, time, data), with each field length-prefixed so crafted input cannot shift the boundaries. Editing, deleting, reordering, or inserting a line breaks the chain at that entry.audit.Verify/VerifyFilewalk a log offline and report the first broken entry.audit.OpenFileresumes an existing chain across restarts.logx verify [-pubkey k] file...checks integrity (exit 0 intact, 1 tampered, 2 unreadable).logx keygenwrites an Ed25519 keypair. Existinglogxpretty-print behavior is unchanged; the verbs dispatch only when they are the first argument.Threat model
Detected: edits, deletes, reorders, insertions; with
-pubkey, forgery or re-signing without the key.Not detected on its own (documented in the package and README): dropping entries from the very end of the file, and a full rewrite of an unsigned log. Sign the log and keep the private key off the writing host; anchor the head hash externally if end-truncation is in scope.
Notes
-race. gofmt -s, go vet, and golangci-lint are clean. Runnable example inexamples/audit.