Sensitive data columns use encryption (at-rest encryption beyond platform defaults)
Why it matters
Platform-level encryption at rest protects the physical disk from theft but does not protect sensitive columns from a compromised database user or a SQL injection attack that reads data directly from tables. SSNs, government IDs, health diagnoses, and biometrics stored as plaintext TEXT columns are fully readable to any session with SELECT access. CWE-311 (missing encryption of sensitive data) and OWASP A02 both require that sensitive fields are protected at the application layer — the database encryption key and the application encryption key must be separately managed so that compromising one does not expose the other.
Severity rationale
Medium because field-level encryption failure exposes the most sensitive personal data to any database-level attacker, but exploitation requires database access beyond typical application-level vulnerabilities.
Remediation
Encrypt sensitive fields (SSNs, government IDs, health data) using AES-256-GCM before writing to the database. Store the encryption key in a secrets manager, not in source code. For payments, store only Stripe token references — never raw card numbers.
// lib/encryption.ts — AES-256-GCM field encryption
import { createCipheriv, createDecipheriv, randomBytes } from 'crypto'
const KEY = Buffer.from(process.env.FIELD_ENCRYPTION_KEY!, 'hex') // 32-byte hex key
export function encrypt(plaintext: string): string {
const iv = randomBytes(12)
const cipher = createCipheriv('aes-256-gcm', KEY, iv)
const enc = Buffer.concat([cipher.update(plaintext, 'utf8'), cipher.final()])
return `${iv.toString('hex')}:${cipher.getAuthTag().toString('hex')}:${enc.toString('hex')}`
}
export function decrypt(ciphertext: string): string {
const [ivHex, tagHex, dataHex] = ciphertext.split(':')
const d = createDecipheriv('aes-256-gcm', KEY, Buffer.from(ivHex!, 'hex'))
d.setAuthTag(Buffer.from(tagHex!, 'hex'))
return d.update(Buffer.from(dataHex!, 'hex')) + d.final('utf8')
}
// Generate key: openssl rand -hex 32
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 Database Design & Operations 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
- soc2:2017 · CC6.1 — Logical access security software, infrastructure, and architectures
- soc2:2017 · C1.1 — Identification and protection of confidential information
Taxons
History
- 2026-04-18·v1.0.0·Initial import from database-design-operations·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.1, C1.1) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2