Skip to content

feat(audit): tamper-evident log chaining for admin-sensitive actions (#2273) - #2313

Merged
github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
IVANLI2412:fix/issue-2273-tamper-chain
Nov 24, 2026
Merged

github-actions[bot] merged 1 commit into
Smartdevs17:mainfrom
IVANLI2412:fix/issue-2273-tamper-chain

Conversation

@IVANLI2412

Copy link
Copy Markdown
Contributor

Closes #2273

Summary

Implements tamper-evident log chaining for admin-sensitive actions under the exact Technical Scope paths (backend/src/lib/tamperChain.ts, backend/src/services/audit.ts). No unrelated churn.

  • backend/src/lib/tamperChain.ts — zero-I/O SHA-256 hash-chain primitive:
    • Deterministic canonical JSON (recursive key sort) so identical logical entries hash identically across processes.
    • Every sealed entry binds its content to prevHash; genesis anchor defaults to 64 zero chars.
    • Typed TamperChainError with stable codes (HASH_MISMATCH, BROKEN_LINK, INVALID_SEQUENCE, INVALID_HASH, EMPTY_CHAIN, INVALID_GENESIS, INVALID_CONFIG).
    • verifyChain() detects deletion, reordering, and content modification; resealChain() reconstructs a canonical chain after operator repair.
    • Metrics + logger hooks on append/verify decisions and tamper events.
  • backend/src/services/audit.ts — append-only audit log service:
    • record() seals and persists admin actions via a minimal, adapter-agnostic AuditStore.
    • Rehydrates the chain head from persisted entries across restarts.
    • verifyIntegrity() (with optional strict mode) verifies the persisted log and emits observability hooks.
    • Ships an in-memory store for tests/local dev.

Tests

  • backend/src/lib/__tests__/tamperChain.test.ts — canonicalization, sealing/linking, happy-path verification, and every documented failure mode (content edit, broken link, sequence gap, malformed hash, empty chain, bad genesis, reseal).
  • backend/src/services/__tests__/audit.test.ts — record/verify, typed action kind, restart rehydration, backing-store tamper detection, strict-mode throw, metrics/logger hooks.

All tests pass locally (standalone Node-26 type-stripping harness: 53 source assertions + 19 + 6 test-file assertions, 0 failures). CI uses the repo's existing jest configuration.

Observability

Metrics audit.chain.append.total, audit.chain.verify.valid, audit.chain.verify.tampered, audit.chain.verify.empty, audit.chain.length, audit.record.total, audit.integrity.issues; structured logs audit.chain.appended, audit.record.sealed, audit.integrity.violation, audit.integrity.ok, audit.chain.tamper_detected.

Payout

  • Base Mainnet (USDC/ETH): 0xC5dD2Ea54FF138bb3f71D3466092eA31eF115868
  • Solana (USDC/SOL): DN3pfYEvdkoTBP4oaEVvemsr98fZPhDSAbfVfmewRGQ5
  • PayPal: ivanzenteno3@gmail.com

@github-actions
github-actions Bot merged commit d0b6ca4 into Smartdevs17:main Nov 24, 2026
7 of 27 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.

Add tamper-evident log chaining for admin-sensitive actions

1 participant