Skip to content

fix(platform): stop false audit tamper alarm on pre-#1676 rows - #2327

Merged
Israeltheminer merged 5 commits into
mainfrom
fix/1842-audit-v1-hash-fallback
Jul 3, 2026
Merged

Israeltheminer merged 5 commits into
mainfrom
fix/1842-audit-v1-hash-fallback

Conversation

@Israeltheminer

Copy link
Copy Markdown
Contributor

Problem

Audit rows written between #1405 (hash chain introduced) and #1676 (canonicalization fix) 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 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 (no actorEmailHash/actorIpHash, which were added later) and the pre-#1676 canonicalization (excludes only integrityHash/previousHash, no undefined-skip). verify_integrity and 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.ts mints 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

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
Israeltheminer and others added 4 commits July 3, 2026 10:00
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]>
@Israeltheminer
Israeltheminer merged commit 9566536 into main Jul 3, 2026
48 of 51 checks passed
@Israeltheminer
Israeltheminer deleted the fix/1842-audit-v1-hash-fallback branch July 3, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: audit rows written between #1405 and #1676 (2026-04-11 → 05-09) permanently fail hash recompute — daily false tamper alarm

1 participant