Punto 3: cadena de auditoría a prueba de dueño #10

Open
cayce wants to merge 0 commits from audit-chain-hardening into main
Owner
  • NULL intermedio ahora falla (antes se saltaba: agujero de tampering)
  • migración 0004: audit_log append-only en SQLite y Postgres
  • verificación de cadena contra anclajes Nostr publicados
  • 10 tests nuevos; gate verde (81+1)
- NULL intermedio ahora falla (antes se saltaba: agujero de tampering) - migración 0004: audit_log append-only en SQLite y Postgres - verificación de cadena contra anclajes Nostr publicados - 10 tests nuevos; gate verde (81+1)
cayce added 1 commit 2026-10-28 19:56:51 +00:00
- verify_audit_chain(): rows with entry_hash IS NULL are only tolerated
  BEFORE the first hashed row (documented legacy prefix). A NULL hash
  AFTER the chain started is tampering and fails verification at that
  row id — previously any NULL row anywhere was silently skipped, so an
  attacker with UPDATE could erase intermediate evidence undetected.
- migration 0004: audit_log becomes append-only. SQLite: BEFORE UPDATE/
  DELETE triggers RAISE(ABORT). Postgres: BEFORE triggers RAISE EXCEPTION.
  Closes the hole for the table owner and direct SQL connections.
- monitor.verify_chain_against_anchors(): compares the chain tail against
  anchors published to Nostr. Explicit statuses: no_anchors (never
  anchored / notes missing on relays), local_only (no fetcher), ok
  (relay note attests the tail or the last local anchor), mismatch.
- tests: NULL-before-genesis ok, NULL-in-middle fails at that id, NULL
  late fails, UPDATE rejected, DELETE rejected, INSERT still allowed,
  no-anchors explicit, local-only explicit, mismatch detected, match ok.

Gate: ruff 0 · 81 unit + 1 PG integration · alembic 0001→0004 on PG ·
gitleaks clean · make check exit 0.
Some required checks failed
ci / lint-test-leaks (pull_request) Canceled after 0s
This branch is already included in the target branch. There is nothing to merge.
This branch is out-of-date with the base branch
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin audit-chain-hardening:audit-chain-hardening
git checkout audit-chain-hardening
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: cayce/cayce-ops#10