Audit System

Immutable audit logging with cryptographic integrity verification

Executive Summary

RayRay implements an append-only audit logging system designed to satisfy NIST 800-53 audit control family requirements. Each event is cryptographically chained using SHA-256 hashes, creating a tamper-evident log that supports forensic analysis and compliance reporting.

Architecture

Hash Chain Integrity

Each audit event includes a hash computed over the event content plus the previous event's hash. This creates a blockchain-style chain where modifying any historical event would break all subsequent hashes.

Event Structure:
┌─────────────────────────────────────┐
│ _id: "evt_abc123"                   │
│ _timestamp: "2026-03-12T15:30:00Z"  │
│ _prev_hash: "sha256:7f8a..." ◀──────┼── Previous event's hash
│ _hash: "sha256:3b2c..."             │   (computed with prev_hash)
│ event_type: "review_approve"        │
│ user_id: 42                         │
│ resource_type: "extraction"         │
│ resource_id: 123                    │
│ outcome: "success"                  │
└─────────────────────────────────────┘

Storage Backend

EnvironmentBackendConfiguration
DevelopmentFileAuditBackend.security/audit/ directory
ProductionS3/Azure BlobPluggable storage interface

NIST Control Mappings

ControlRequirementImplementation
AU-2Audit EventsComprehensive CUD operation logging
AU-3Content of Audit RecordsTimestamp, user, IP, resource, action, outcome
AU-4Audit Storage CapacityDaily rotation, configurable retention
AU-5Response to Audit FailuresAlerting on write failures
AU-6Audit ReviewQuery API for analysts and auditors
AU-9Protection of Audit InformationSHA-256 hash chain prevents tampering
AU-11Audit Record Retention7-year default (configurable)

Event Types

Event TypeDescriptionLogged Data
document_uploadDocument submittedfilename, file_size, user_id
extraction_startAI extraction initiateddocument_id, ai_model, ai_provider
extraction_completeAI extraction finishedextraction_count, confidence, processing_time
review_approveHuman approved extractionsworkflow_run_id, extraction_count, notes
review_modifyHuman modified extractionsworkflow_run_id, modified_fields
review_rejectHuman rejected extractionsworkflow_run_id, rejection_reason
export_downloadReport exportedformat, document_count, comparison_id

API Endpoints

Query Audit Events

GET /api/audit/events?start_time=2026-03-01&end_time=2026-03-12&event_types=review_approve,review_reject

Response:
{
  "events": [
    {
      "_id": "evt_abc123",
      "_timestamp": "2026-03-12T15:30:00Z",
      "event_type": "review_approve",
      "user_email": "reviewer@agency.gov",
      "resource_type": "extraction",
      "outcome": "success"
    },
    ...
  ],
  "total": 147,
  "has_more": true
}

Verify Integrity

GET /api/audit/verify

Response:
{
  "valid": true,
  "events_checked": 1847,
  "date_range": {
    "start": "2026-01-15",
    "end": "2026-03-12"
  },
  "first_failure": null,
  "errors": []
}

Export for External Audit

GET /api/audit/export?format=json

Response: application/jsonl
(event log as JSON Lines format)

Integrity Verification Procedure

The verification endpoint recomputes all hashes and validates the chain integrity. This procedure should be run:

  • Before any compliance audit
  • After system maintenance
  • As part of continuous monitoring (automated daily)
# Automated verification (cron)
0 6 * * * curl -s https://rayray.example.com/api/audit/verify | grep -q '"valid":true' || alert-team.sh

Retention Policy

Event CategoryRetention PeriodRationale
Security Events7 yearsFedRAMP/NIST requirement
Review Events7 yearsM-25-21 audit trail
Export Events3 yearsOperational tracking

Related