Repository navigation
fix(platform): stop false audit tamper alarm on pre-#1676 rows - #2327
Merged
Merged
Conversation
Audit rows written between #1405 and #1676 were hashed by a canonicalizer that emitted "field":undefined tokens for absent optional fields. The modern canonicalizer skips those keys, so every such row's stored integrityHash is unreproducible from the stored document: the daily integrity cron reported a critical "hash chain broken" tamper alarm for every affected org with no tampering involved, and the oldest-first walk stopped at the first v1 row, masking any real tampering later in the chain. Add a frozen v1 hashing path (computeAuditHashV1Legacy + buildAuditRecordHashInputV1Legacy, pinned to the exact 21-field v1 record and the pre-#1676 canonicalization) and fall back to it in verify_integrity and the inline write self-check ONLY when the modern recompute mismatches. A genuinely tampered v1 row fails both recomputes, so tamper-evidence is preserved; healthy modern chains never touch the fallback. Regression tests mint a real v1-era hash from an independent oracle and assert the verifier accepts it, still flags a tampered v1 row, and verifies a mixed v1-then-modern chain without masking. Closes #1842
Use the shared type-utils isRecord in audit_hash and the v1 test oracle instead of local duplicates, keeping null-before-typeof ordering. Co-authored-by: Cursor <[email protected]>
Remove unused toast import in project-secrets-tab tests and run oxfmt on project-secrets-tab.tsx brought in by the main merge. Co-authored-by: Cursor <[email protected]>
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.
Problem
Audit rows written between #1405 (hash chain introduced) and #1676 (canonicalization fix) were hashed by a canonicalizer that emitted
"field":undefinedtokens for absent optional fields. The modern canonicalizer skips those keys, so every such row's storedintegrityHashis unreproducible from the stored document. The daily integrity cron walks oldest-first, hits the first v1-era row, and fires a critical "hash chain broken" tamper alarm (audit row + notification + Slack) for every affected org, every day, with zero tampering. The walk also stops there, masking any real tampering later in the chain.Fix
A frozen v1 hashing path —
computeAuditHashV1Legacy+buildAuditRecordHashInputV1Legacy, pinned to the exact 21-field v1 record (noactorEmailHash/actorIpHash, which were added later) and the pre-#1676 canonicalization (excludes onlyintegrityHash/previousHash, no undefined-skip).verify_integrityand the inline write self-check retry via this path only when the modern recompute mismatches, and accept a v1 match. A genuinely tampered v1 row fails both recomputes, so tamper-evidence is preserved and real breaks later in the chain are no longer masked. Non-destructive — no data rewrite, no schema change/migration.Tests
chain_integrity_hardening.test.tsmints a real v1-era hash from an independent oracle and asserts the verifier (a) accepts it while the modern recompute rejects it, (b) still flags a tampered v1 row, (c) verifies a mixed v1-then-modern chain without masking. 12/12 green; typecheck + lint clean.Closes #1842