CCyberwiki

Personal data in logs

Personal data in logs
ClassData exposure
Also known asSensitive information in log files
CWECWE-532: Insertion of Sensitive Information into Log File
OWASP Top 10A09:2025 Security Logging and Alerting Failures
Typical severityMedium
AffectsRequest and error logging in application code, web server access logs, error tracking services and CI build logs

A sign-in handler that prints its whole request body puts each user's password into a log. Personal data in logs is the name for the vulnerability behind that line, in which software "writes sensitive information to a log file".1 Besides passwords, the values that end up there include tokens, payment card numbers and personal details. Recording personal or health data that should never be logged counts as a logging failure in its own right.2

Description

Logs come from the application, from the web server or reverse proxy in front of it, from error tracking services and from build systems. They exist to show detail and are copied widely, so one logged value can end up "on end devices, at intermediate points, in centralized repositories and in archives and backups".3

Passwords, session identifiers, access tokens, connection strings, encryption keys, card holder data, and health and government identifiers should never go into a log as they are. Each is removed, masked, hashed or encrypted first. Names, phone numbers and email addresses need special handling before they are recorded.3

Mechanism

The plainest case is a debug line that prints a whole object. Here a sign-in route in an Express application logs the request body:

app.post("/login", async (req, res) => {
  console.log("login attempt", req.body);
  // ...
});

Every sign-in then writes a line such as login attempt { email: 'anna@example.com', password: 'hunter2' } to the application log. In Java the same slip looks like an exception handler that logs a whole user object, and with it the user's location.1

Secrets in URLs reach the log by another way. By default nginx logs each request in its combined format, which contains the full request line.4 A reset link such as /reset?token=8f3c, or a query string holding an email address, is therefore written to the access log. The same values can stay in browser history and travel to other sites in the Referer header.5

A stack trace or database error logged in full can carry query details and table names.1 In CVE-2018-1999036 an SSH password was stored in a build log, and in CVE-2017-9615 verbose logging wrote administrator credentials to a file any local user could read.1

Impact

The log turns into "an additional, less-protected path" to the same information.1 A password table may be hashed and a customer table protected by access rules, while the log that recorded the same values in plain text is readable by everyone with access to the hosting dashboard, the log service or a backup. Whoever reaches the logs, through a leaked account, an exposed log file or a copied backup, obtains the data without breaking the stronger controls, and a session token found there opens the way to Session hijacking.

Notable incidents

On 21 March 2019 Facebook announced that a routine security review in January had found user passwords "stored in a readable format within our internal data storage systems", although its login systems hash passwords with scrypt. It estimated that it would notify hundreds of millions of Facebook Lite users, tens of millions of other Facebook users and tens of thousands of Instagram users. An update on 18 April 2019 reported "additional logs of Instagram passwords" and raised the Instagram estimate to millions. The company said it had found no evidence of internal abuse.6

The Irish Data Protection Commission opened an inquiry in April 2019 and on 26 September 2024 issued a reprimand and fines totalling €91 million. It found that Meta had failed to notify and to document the breach under Articles 33(1) and 33(5) of the GDPR, and had not applied appropriate security measures to the passwords under Articles 5(1)(f) and 32(1). The passwords had not been made available to anyone outside the company.7

Detection

Search the source code for log calls that receive whole objects, such as console.log(req.body), logger.info(user) or JSON.stringify(req.headers), and for log calls in sign-in, payment and password reset routes. Search for URLs that place tokens, email addresses or passwords in the query string. Then search the stored logs for password, Bearer , token= and the @ of email addresses.

Prevention

Log chosen fields

Write the fields an investigation needs, such as a user ID, the action and the result, instead of whole bodies, headers or user objects. To follow one session across events, log a hashed value of its ID; where nobody needs to know who the person is, delete, scramble or pseudonymise the identifier.3 Remove debug log files and adjust the logging settings before the application goes to production.1

Redact in the logger

In the Pino logger for Node.js, the redact option takes a list of paths; matching values are written as [Redacted], and remove: true drops the key entirely. Paths are case sensitive and accept * as a wildcard.8

const pino = require("pino");
const logger = pino({
  redact: {
    paths: ["password", "req.headers.authorization", "req.headers.cookie", "user.email", "card.number"],
    remove: true
  }
});

Redaction by field name catches only the names listed; a password inside a free-text message is still written.

Error tracking services

Sentry scrubs data on its servers by default. It removes values that look like card numbers and values whose content or key name contains strings such as password, secret, api_key, auth, token and bearer. Further field names are added under Project Settings > Security & Privacy in Additional Sensitive Fields, where the storage of IP addresses can also be turned off.9

Access and retention

Tokens and personal data belong in the request body or headers, not in the URL.5 Keep logs out of any folder the web server hands out, limit who can read them, and delete them when the required retention period ends.3 See Principle of least privilege and Secrets management.

Prompt for a coding agent

Find every place in this project that writes to a log: console.log, console.error, logger calls, error tracking calls and request logging middleware. Report each call that logs a whole request body, request headers, a user object, an error object with request data, or any field named password, token, secret, authorization, cookie, email, phone or card. Rewrite each one to log only the user ID, the action and the result. Add redaction to the logger configuration for the sensitive field names. Find any URL that carries a token, password or email address in its query string and move the value to the request body or a header. List each file and line you changed.

In SecFlash

SecFlash reports a password, token, email or card number in a page address as SF-SEC-638 and a session ID in the address as SF-SEC-654, since addresses are written to server logs. A readable ELMAH error log, which holds the cookies and form data of visitors, is SF-SEC-649. A GitHub Actions workflow that can print a credential to its log is SF-SEC-805. All four show on the Security page.

See also

References

  1. a b c d e f "CWE-532: Insertion of Sensitive Information into Log File". Common Weakness Enumeration. MITRE.
  2. back "A09:2025 Security Logging and Alerting Failures". OWASP Top 10:2025. OWASP Foundation.
  3. a b c d "Logging Cheat Sheet". OWASP Cheat Sheet Series.
  4. back "Module ngx_http_log_module". nginx documentation.
  5. a b "CWE-598: Use of HTTP Request With Sensitive Query String". Common Weakness Enumeration. MITRE.
  6. back Canahuati, Pedro (21 March 2019, updated 18 April 2019). "Keeping Passwords Secure". Meta Newsroom.
  7. back Data Protection Commission (27 September 2024). "Irish Data Protection Commission fines Meta Ireland €91 million". dataprotection.ie.
  8. back "Redaction". Pino documentation. GitHub.
  9. back "Server-Side Data Scrubbing". Sentry Docs. Sentry.