Context
Compliance requirements (SOC2, PCI-DSS) demand tamper-evident audit logs for all sensitive operations.
Current Limitation/Problem
Audit logs are stored in a regular database table that can be modified by database administrators or through SQL injection. There is no tamper evidence.
Expected Outcome
An immutable audit trail using a hash chain where each log entry contains the hash of the previous entry, with periodic hash anchors to a public blockchain.
Acceptance Criteria
- All sensitive operations logged: auth, payment, configuration changes, admin actions
- Each log entry contains:
{ id, timestamp, actor, action, resource, details, previousHash, hash }
- Hash chain:
hash = SHA256(previousHash + timestamp + actor + action + resource + details)
- Periodic anchor: append latest hash to public blockchain (Ethereum or Stellar) as proof
- Verification tool: verify audit log integrity from genesis
- Query performance: index on timestamp, actor, action for search
- Log retention: hot (30 days in DB), warm (1 year in S3), cold (7 years in Glacier)
- Tamper detection alert when hash chain inconsistency found
- Export audit log for compliance review
Technical Scope
backend/src/audit/ - audit service
backend/src/audit/immutable-logger.ts - hash chain logger
backend/src/audit/chain-verifier.ts - integrity verification
backend/src/audit/anchor-service.ts - blockchain anchoring
- Prisma:
AuditLog model (hash chain)
- S3 archiver for warm/cold storage
- Frontend:
/admin/audit-log - audit log viewer with verification
- Edge cases: hash collision, blockchain anchor cost, concurrent log writes, log pruning
Context
Compliance requirements (SOC2, PCI-DSS) demand tamper-evident audit logs for all sensitive operations.
Current Limitation/Problem
Audit logs are stored in a regular database table that can be modified by database administrators or through SQL injection. There is no tamper evidence.
Expected Outcome
An immutable audit trail using a hash chain where each log entry contains the hash of the previous entry, with periodic hash anchors to a public blockchain.
Acceptance Criteria
{ id, timestamp, actor, action, resource, details, previousHash, hash }hash = SHA256(previousHash + timestamp + actor + action + resource + details)Technical Scope
backend/src/audit/- audit servicebackend/src/audit/immutable-logger.ts- hash chain loggerbackend/src/audit/chain-verifier.ts- integrity verificationbackend/src/audit/anchor-service.ts- blockchain anchoringAuditLogmodel (hash chain)/admin/audit-log- audit log viewer with verification