① Key management (B3/KMS): vault-kms.sh gains `rotate` (Transit key rotation) and `assert-nonexportable` (proves private material never leaves the KMS). Validated live against a Vault dev server: sign→verify (v1) → rotate → sign→verify (v2) → export denied. sign-audit-head.sh already routes to Vault when VAULT_ADDR/TOKEN are set, so this is the real production signing path. ② External WORM audit (C5/V21): worm-ledger.py + audit-ship.sh append the audit head to a hash-linked append-only ledger (chattr +a best-effort on Linux; S3 Object Lock/QLDB in production). verify-audit-gap.sh detects local audit rollback (AUDIT_GAP_DETECTED — the durable ledger still holds the later head) and ledger tampering (AUDIT_LEDGER_TAMPERED). phase-h5-infra-tests.sh: 7 checks — KMS sign/rotate/non-exportable (skip-aware, live when Vault reachable) + WORM in-sync/rollback/tamper (always local). Baselines: run-casan4 35/35, adversarial 44/44, approval 8/8. Lifts H5 key-mgmt 2.5→~4 (KMS live path + rotation + non-exportable) and external-audit 1.5→~3.5 (WORM ledger + gap detection). Suites now 7 (+7 = 155 checks). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
20 lines
936 B
Bash
Executable File
20 lines
936 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -uo pipefail
|
|
|
|
# CASAN H5 — Detect audit rollback / evidence deletion vs the WORM ledger (C5/V21).
|
|
# Verifies the external anchor ledger is internally intact (hash-linked) AND that
|
|
# the local audit head has not been rolled back below the durable anchor. Deleting
|
|
# the tail of the local audit log surfaces as AUDIT_GAP_DETECTED because the WORM
|
|
# ledger still holds the later head.
|
|
#
|
|
# Usage: verify-audit-gap.sh [head-file] [ledger-file]
|
|
# Exit: 0 in-sync, 1 tamper/gap/unshipped, 64 usage.
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
HEAD_FILE="${1:-$PROJECT_ROOT/.specify/logs/audit/audit-head.txt}"
|
|
LEDGER="${2:-${CASAN_WORM_LEDGER:-$PROJECT_ROOT/.specify/logs/worm/anchor-ledger.jsonl}}"
|
|
|
|
[[ -f "$HEAD_FILE" ]] || { echo "AUDIT_GAP_NO_HEAD file=$HEAD_FILE" >&2; exit 1; }
|
|
python "$SCRIPT_DIR/worm-ledger.py" verify "$HEAD_FILE" "$LEDGER"
|