Encryption at rest for sensitive data
Why it matters
Storing SSNs, health records, or payment card data as plaintext in a database means a SQL injection, a misconfigured backup, or a rogue employee with SELECT privileges can access the raw values immediately. CWE-311 (Missing Encryption of Sensitive Data) and OWASP A02 (Cryptographic Failures) classify this as a high-severity failure. NIST 800-53 SC-28 mandates encryption of information at rest for sensitive categories. Infrastructure-level disk encryption (RDS encryption, full-disk) does not protect against application-layer attacks or insider queries — field-level AES-256-GCM encryption is the only control that survives a database dump.
Severity rationale
High because plaintext sensitive fields are fully exposed to any party with database read access — a single SQL injection or insider query bypasses all other controls.
Remediation
Encrypt sensitive fields before writing them to the database using AES-256-GCM with a randomly generated IV per record:
import crypto from 'crypto'
const KEY = Buffer.from(process.env.ENCRYPTION_KEY!, 'hex') // 32-byte hex key
function encrypt(text: string): string {
const iv = crypto.randomBytes(16)
const cipher = crypto.createCipheriv('aes-256-gcm', KEY, iv)
const enc = Buffer.concat([cipher.update(text, 'utf8'), cipher.final()])
const tag = cipher.getAuthTag()
return `${iv.toString('hex')}:${tag.toString('hex')}:${enc.toString('hex')}`
}
Store ENCRYPTION_KEY in AWS Secrets Manager or HashiCorp Vault — not in a .env file alongside the data it protects. Fields eligible for a HIPAA or PCI skip (e.g., Stripe-tokenized cards) need documented evidence of third-party handling.
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 Security Hardening Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-311 — Missing Encryption of Sensitive Data
- owasp:2021 · A02 — Cryptographic Failures
- nist:rev5 · SC-28 — Protection of Information at Rest
- soc2:2017 · C1.1 — Identification and protection of confidential information
Taxons
History
- 2026-04-18·v1.0.0·Initial import from security-hardening·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (C1.1) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2