Repository navigation
feat(audit): make audit records tamper-evident and queryable - #142
Open
woahwhattheheck wants to merge 11 commits into
Open
woahwhattheheck wants to merge 11 commits into
woahwhattheheck wants to merge 11 commits into
Conversation
Add hash-chained integrity metadata, redacted attribution fields, duplicate outcome suppression, and authorized filters so transfer investigations can detect silent tampering and correlate privileged mutations without exposing secrets.
An actual HTTP archive/unarchive/archive/unarchive sequence returned four successful state changes but only two audit outcomes when the caller reused a correlation ID. The later mutations were suppressed as retries while integrity still reported a valid, incomplete trail. Add optional mutationId to audit records and derive it from the existing monotonic updatedAt for archive/unarchive. Include normalized actor, scope and state-change identity in the structured replay key, preserving caller correlation fields and legacy first-write-wins behavior. Bind the optional ID in the integrity hash; entries without it retain their prior field shape and hash calculation. Archive no-ops still add no event. Three new regressions fail on the previous source. The actual app now records all six state changes across three cycles under the same correlation, including actor changes and repeated archive no-ops. Explicit mutation replay, actor/scope isolation and mutation-ID tamper detection pass. Existing creation-replay and redaction cases remain intact. Validation: npm test passes 273/273, 0 failed, 0 skipped; audit suite 17/17; git diff --check passes. Executing the previous auditCrypto implementation against a current legacy entry confirms the original hash is preserved. Node24.19.0 with the exact existing package-lock dependency tree; no dependency changes. Operation: REMIT142-AUDIT-CYCLE-20261003-443D
Verify resourceId, requestId, and payload against their hash-bound canonical fields without changing stored hashes. Equivalent payload copies stay valid. Three HTTP regressions fail on prior source. Full npm test: 277 passed.
Privileged transfer and user mutations now pass raw credentials through the explicit actorToken input. Always fingerprint that input, including actor-prefixed, fingerprint-shaped and literal system tokens, while preserving legacy precomputed references, actor-scoped replay, archive-cycle identities and compatibility-alias integrity checks. Actual createApp HTTP: 44 requests across four configured synthetic-token profiles. All mutation outcomes remain successful, each profile retains seven audit events, fingerprint filtering returns those events, retries reuse the original transfer and integrity remains valid. The three lookalike profiles previously stored the raw credential and returned zero results for its fingerprint. Node 24.19.0, all 76 retained package-lock versions exact, no install. npm test -- --test-concurrency=1: 280 pass, 0 fail/skips. Focused audit suite: 24 pass; unchanged parent source with the same tests: 21 controls pass and three added regressions fail. Four changed JS files pass node --check; git diff --check passes. The HTTP exercise uses the repository's existing mock settlement adapter; no external settlement or Node 22 run is claimed.
Document authenticated audit filters, opaque actor references, and inspecting valid even when the integrity endpoint returns HTTP 200. Explain the existing import-time secret precedence and process-local chain lifetime in the README and environment template. Source and complete documentation readback are the verification for this continuation. Runtime and maintained tests were not rerun during the execution environment outage; prior source verification remains historical.
Assigning a parsed __proto__ key to a plain clone invokes the inherited setter. The key then disappears from serialized changes and the canonical event hash, so editing that evidence does not change the hash. Construct own data properties during recursive redaction to retain the field while still redacting secrets nested beneath it. Add three maintained node:test cases for own-key and prototype preservation, nested redaction plus JSON round trips, mutation-sensitive event hashes, and the unchanged canonical digest for ordinary JSON. On the preceding source, two regressions fail and the compatibility control passes. All three pass after this change on Node 24.19.0: node --test test/auditCrypto.test.js Both changed files also pass node --check. The current full Express/HTTP suite was not run; these tests use the actual module and Node built-ins. No dependency, hash format, actor identity, replay, or storage change.
Preserve canonical bytes, existing integrity hashes and sparse-array handling while avoiding temporary item arrays. Include paired measurements and the reusable benchmark for the production encoder and hash function.
Catch failures from hash recomputation and compatibility payload encoding. Return the broken index and a fixed reason without exposing the payload exception or changing stored hashes. Add two focused regressions covering cyclic changes and a throwing payload accessor.
Author
|
Current-head QA at |
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 #127
Problem
Sensitive transfer investigations are unreliable if audit records can be changed silently or cannot be correlated to a request.
What this PR does
chainSeq,prevHash, andentryHash(SHA-256 over a canonical payload).verifyIntegrity()/GET /api/audit/integrityrecomputes the chain.outcome: successevent. Retries with the same(action, target, correlationId, outcome)return the existing entry instead of appending.GET /api/auditremains behindaudit:read. New filters:action,scope,outcome,correlationId,actor. Changes are redacted at write; actors are HMAC fingerprints, never raw tokens.Design tradeoffs
resourceId/requestId/payloadcontinue to work alongsidetarget/correlationId/changes.Compatibility impact
GET /api/audit.GET /api/audit/integrity(audit:read).AUDIT_ACTOR_SECRET(falls back toPAGINATION_CURSOR_SECRET).Tests
test/auditIntegrity.test.jscovers:prevHashis detectedVerification
Baseline on
upstream/mainwas 256. No unrelated tests were skipped, deleted, or weakened.Out of scope