OPS-9Required
Keep personal data out of logs
Never log passwords, tokens, full card numbers or personal details. Log IDs instead, and drop or shorten IP addresses.
How to do it
Redact known fields in the logging library, such as authorization, password and email. Examples are pino's redact in Node.js, a logging filter in Python, or a Monolog processor in PHP. Log a customer ID instead of a name. An ID or an IP address still points to a person, so the law treats it as personal data. The logs still need a retention limit. Drop IP addresses from access and app logs, or shorten them, such as to the first three parts of an IPv4 address. Drop query strings from access logs. Scrub the same fields from what an error tracker sends, such as request bodies, headers and cookies. The security testing playbook shows how to test for leaks.
Examples
JavaScript example
const log = pino({ redact: ['req.headers.authorization', 'password', 'email', 'card', '*.password', '*.email', '*.card'] });
Python example
import logging
SECRET_FIELDS = {"authorization", "password", "email", "card"}
class RedactFields(logging.Filter):
def filter(self, record):
for field in SECRET_FIELDS & record.__dict__.keys():
setattr(record, field, "[redacted]")
return True
logging.getLogger("shop").addFilter(RedactFields())
How to check
Sign in, reset a password and place a test order on staging from a known IP address. Search the logs and the error tracker's events for the test password, token, email address and full IP address. None of them appear.
Sources
- OWASP Logging Cheat Sheet
- GDPR Recital 26 on identifiable persons
- CJEU case C-582/14 Breyer on IP addresses
Related rules
- AID-76 Redact secrets from agent session logs in AI-assisted development
- DAT-70 Put the tenant on every log line and trace in Data and databases
- EML-54 Keep email logs lean in Email
- OPS-10 Keep logs for a fixed time in Operations and observability
- APS-79 Keep private data out of logs and addresses in Application security
- AIF-48 Keep prompt and answer text briefly and apart in AI features
- ACC-74 Keep national ID numbers out of your data in Accounts and identity
- STK-66 Use GlitchTip for error tracking in Software choices
- MOB-23 Keep personal data out of device logs in Mobile apps
- MLO-25 Log the features and prediction of every request in Machine learning
- ANA-8 Keep personal data out of events in Product analytics and experiments
- ANA-9 Hide personal data from session recordings in Product analytics and experiments
- SRH-12 Keep personal data out of search logs in Search
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/operations/logs/logs-without-personal-data">Agent Wranglers operations and observability playbook</a>. In code you write, add a comment next to it with the same link.