Audit logs retained per regulatory requirement
Why it matters
GDPR Article 30(1) requires records of processing activities to be maintained — without a defined retention window, these records will either grow unbounded (prompting an engineer to delete them without proper review) or get purged on an arbitrary schedule shorter than regulatory requirements. GDPR Article 5(2) accountability and CCPA §1798.185(a)(8) both require that records demonstrating compliance be available for regulatory inspection. Common guidance across CAN-SPAM, GDPR, and state privacy laws converges on 3-5 years for consent and processing records. A 90-day purge window — common in log management systems — falls catastrophically short of this.
Severity rationale
Medium because incorrect retention periods create a gap between when records are purged and when a regulatory inquiry or litigation hold might require them, leaving the business unable to demonstrate compliance for historical processing activity.
Remediation
Define retention constants explicitly in code and use them in all purge jobs — never hardcode day counts at the call site:
// src/lib/compliance/constants.ts
export const AUDIT_LOG_RETENTION_DAYS = 1825 // 5 years (conservative)
export const CONSENT_RECORD_RETENTION_DAYS = 1825
// src/lib/compliance/purge.ts — runs as a monthly cron job
import { AUDIT_LOG_RETENTION_DAYS } from './constants'
export async function purgeExpiredAuditLogs() {
const cutoff = new Date()
cutoff.setDate(cutoff.getDate() - AUDIT_LOG_RETENTION_DAYS)
const { count } = await db.auditLog.deleteMany({
where: { createdAt: { lt: cutoff } }
})
await logger.info('audit-log-purge', { deletedCount: count, cutoff })
}
Add a code comment on AUDIT_LOG_RETENTION_DAYS explaining the regulatory basis so future engineers understand why this constant cannot be reduced without a legal review.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Compliance & Consent Engine Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- gdpr · Art. 30(1) — Records of processing activities — must be maintained and available to supervisory authority
- gdpr · Art. 5(2) — Accountability — must be able to demonstrate compliance
- ccpa · §1798.185(a)(8) — Recordkeeping obligations — 24-month minimum
- iso-27001:2022 · A.8.10 — Information deletion — retention periods must be defined
- nist:rev5 · AU-11 — Audit record retention
Taxons
History
- 2026-04-18·v1.0.0·Initial import from compliance-consent-engine·automated