Error logs scrubbed of sensitive data
Why it matters
Error logs that contain email addresses, passwords, API keys, or session tokens become a secondary attack surface. CWE-209 (information exposure through error messages) and OWASP A09 (security logging and monitoring failures) both cover this failure mode. NIST SP 800-53 AU-3 requires audit records to contain the right information — but not uncontrolled PII or credentials. A compromised logging pipeline or accidental log export can expose the credentials of every user whose request happened to error during a specific window.
Severity rationale
Info severity because exploitation requires log access, which typically requires a separate compromise — but when that compromise occurs, unredacted logs amplify every credential in them.
Remediation
Configure a beforeSend hook in your error tracking service to strip PII and secrets before they leave the process. Apply the same sanitization to your structured logger.
// lib/sentry.ts
Sentry.init({
dsn: process.env.SENTRY_DSN,
beforeSend(event) {
if (event.request?.data) {
const data = event.request.data as Record<string, unknown>
delete data.password
delete data.token
delete data.authorization
}
return event
},
})
For your logger, sanitize at the call site with a helper: logger.info({ user: omit(user, ['passwordHash', 'mfaSecret']) }, 'User action'). Never log raw request bodies without stripping credential fields first.
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 Error Resilience Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-209 — Generation of Error Message Containing Sensitive Information
- owasp:2021 · A09 — Security Logging and Monitoring Failures
- nist:rev5 · AU-3 — Content of Audit Records
- soc2:2017 · CC6.7 — Restriction of information transmission, movement, and removal
Taxons
History
- 2026-04-18·v1.0.0·Initial import from error-resilience·automated
- 2026-07-06·v1.0.1·Add SOC 2 TSC mapping (CC6.7) from the verified compliance crosswalk register (docs/compliance/).·by soc2-mapping-enrichment-ship-2