No sensitive data in logs
Why it matters
CWE-532 (Insertion of Sensitive Information into Log File) is a direct path to credential theft: password hashes, session tokens, and API keys logged to stdout end up in your log aggregation platform, which typically has far weaker access controls than your primary database. PCI-DSS Req 10.3.3 explicitly prohibits logging cardholder data in any form; GDPR Art. 32 requires appropriate safeguards for personal data at rest and in transit — your log store is both. A single logger.info(req.body) in a payment handler can land card numbers, CVVs, and billing addresses in a third-party SaaS log platform, creating a compliance violation that persists for your entire log retention window. OWASP A09 lists sensitive data in logs as a primary logging failure mode.
Severity rationale
Critical because logged secrets, tokens, or PII remain exploitable for the full log retention period and may be exfiltrated from log infrastructure, which is rarely as hardened as your primary data store.
Remediation
Never log objects wholesale. Select only the fields you need, using explicit destructuring or field picks.
// WRONG — leaks everything in the user object including passwordHash
logger.info(user)
logger.debug(req.body)
// RIGHT — log only non-sensitive identifiers
logger.info({ userId: user.id }, 'User action')
logger.debug({ path: req.path, method: req.method }, 'Request received')
For Sentry, add a beforeSend scrubbing hook in your Sentry config file:
Sentry.init({
dsn: process.env.SENTRY_DSN,
beforeSend(event) {
if (event.request?.data) { delete event.request.data }
return event
}
})
After patching, run grep -r 'logger\.(info|debug|error)(user\|req\.body\|ctx)' app/ lib/ to confirm no wholesale object logging remains.
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 Logging & Monitoring Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-532 — Insertion of Sensitive Information into Log File
- owasp:2021 · A09 — Security Logging and Monitoring Failures
- nist:rev5 · AU-3 — Content of Audit Records
- pci-dss:4.0 · Req 10.3.3 — Audit logs are protected from destruction and unauthorized modifications
- gdpr · Art. 32 — Security of processing
- soc2:2017 · CC6.7 — Restriction of information transmission, movement, and removal
- soc2:2017 · CC7.2 — Monitoring for anomalous system activity
Taxons
History
- 2026-04-18·v1.0.0·Initial import from saas-logging·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.7, CC7.2) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2