Skip to content

fix(audit): bind attribution into the HMAC anchor (v3) — catch sealed-entry de-attribution - #177

Merged
sandstream merged 1 commit into
mainfrom
claude/headroom-kit-integration-cmjw7t
Jun 30, 2026
Merged

sandstream merged 1 commit into
mainfrom
claude/headroom-kit-integration-cmjw7t

Conversation

@sandstream

Copy link
Copy Markdown
Owner

Description

The deferred finding from the deep adversarial pass (complements #175). The audit attribution layer had one unguarded move: a writer-only attacker — no private key, no anchor key — could strip or rewrite kid/sig on an entry that was already signed AND anchored, and every layer still reported green:

  • the keyless chain re-hashes the line without kid/sig, so it stays intact;
  • verifyAuditSignatures just re-counts the entry as unsigned → fail-open;
  • the old HMAC anchor folded only hash, so the sealed tip was byte-identical.

Net: the author of a sealed prod-write record could be silently erased or re-tagged.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • Anchor seal now folds attribution. New computeAnchorTipV3 chains the HMAC over hash | kid | sig per line (unit-separated; own domain seed kit-audit-anchor/v3). Anchor records are written at version: 3.
  • Strip / rewrite of a sealed entry's signer now moves the tip → hard tip-mismatch. Forging a kid/sig onto a sealed keyless entry is caught the same way (keyless seals with empty attribution).
  • Backward-compatible + self-migrating. verifyAgainstAnchor picks the fold algorithm from the record's version, so legacy v ≤ 2 anchors keep verifying hash-only until the next kit audit anchor re-seals them as v3.
  • Deliberately not changed: signing still covers hash alone. Binding kid into the signature adds nothing for this threat — a relabel to a known key already fails verification, and strip / unknown-relabel fail-open regardless. The anchor is the authoritative seal, so that's where attribution is bound. (Rationale in the commit body.)
  • Updated docs/AUDIT_ATTESTATION.md (retracts the gap, documents v3) + CHANGELOG.

Testing

Test Coverage

  • Added new tests (3 regression cases in audit-anchor.test.ts)
  • Updated existing tests (the v2→v3 record-version assertion)
  • All tests pass (npm test) — 1945 pass, 0 fail

Manual Testing

  1. computeAnchorTipV3 moves when kid/sig change; the legacy hash-only tip does not (documents the exact gap).
  2. A v3 anchor reports tip-mismatch after a sealed entry's kid is stripped; anchored-ok for the untampered log.
  3. A legacy v2 record still verifies hash-only (back-compat) and — as designed before v3 — is blind to the strip.

🤖 Generated with Claude Code

https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg


Generated by Claude Code

…-entry de-attribution

The deep adversarial pass found the audit attribution layer's one unguarded
move: a writer-only attacker (no private key, no anchor key) could STRIP or
rewrite kid/sig on an entry that was already signed AND anchored, and every
layer stayed green — the keyless chain re-hashes without kid/sig, the signature
tally re-counts the entry as `unsigned` (fail-open), and the hash-only anchor
tip was byte-identical.

Fix: the HMAC anchor now folds attribution into the seal. New
`computeAnchorTipV3` chains over `hash | kid | sig` per line (unit-separated;
own domain seed), and anchor records are written at `version: 3`. Altering or
removing the signer of any ANCHORED entry now moves the tip → hard
`tip-mismatch`; forging kid/sig onto a sealed keyless entry is caught the same
way. `verifyAgainstAnchor` picks the fold algorithm from the record version, so
legacy v≤2 anchors keep verifying hash-only until the next `kit audit anchor`
re-seals them as v3 (backward-compatible, self-migrating).

Not changed: signing over `hash` alone is kept — binding kid into the signature
adds nothing here (a relabel to a known key already fails verification; strip /
unknown-relabel fail-open regardless). The anchor is the authoritative seal, so
that is where attribution is bound.

Adds 3 regression tests (v3 tip moves on kid/sig change; v3 verify catches the
strip; legacy v2 stays hash-only). Updates docs/AUDIT_ATTESTATION.md + CHANGELOG.
1945 tests pass.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ERHw6bVUz39sAuoQZ1iyg
@github-actions

Copy link
Copy Markdown

✅ Docker image built successfully

  • CLI image: docker.io/sandstream/kit:test

@sandstream
sandstream merged commit d879942 into main Jun 30, 2026
17 checks passed
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.

2 participants