Mask personal data and secrets in log files
Logs are the most useful thing to attach to a bug report and one of the riskiest. A few hundred lines from a web server or an app usually contain client IP addresses, email addresses, session tokens and sometimes a key someone logged by mistake.
What a log typically gives away
- IP addresses, IPv4 and IPv6, of clients and internal hosts. Under the GDPR an IP address can be personal data.
- Emails and user names in request parameters, audit lines or error messages.
- Secrets: bearer tokens and JWTs in headers, API keys with known prefixes (
sk_live_,ghp_,AKIA), passwords in connection strings such aspostgres://user:password@host. - Internal names: host names like
db01.prod.internal, MAC addresses, URLs of admin panels.
Keep it useful: stable pseudonyms
Deleting every value makes a log useless for debugging: you can no longer see that the same client made the three failing requests. Replace values with stable pseudonyms instead. In the Anonymizer, the Log file preset uses hashes: the same IP address becomes the same code, such as IP_7f3a01bc, on every line, and different addresses get different codes.
The log preset leaves name detection off, since capitalized words in logs are rarely names, and keeps everything with a fixed format on: IPs, MAC addresses, emails, URLs and host names, keys and passwords, card numbers and IBANs.
Step by step
- Open the anonymizer and choose Open file, or drop the log onto the text box. The file is read by your browser and never uploaded; files up to 5 MB fit.
- The Log file preset is picked for
.logfiles. Check the findings and switch categories on or off. - Add anything specific to your system to the custom terms list: customer names, project code names, internal domains.
- Download the result. It keeps the file name, with
.anonymizedbefore the extension.
Before you send
- Rotate any secret that appeared in the log, whether you redacted it or not. Logs get copied to places you don't control.
- Skim the result for values in odd formats: a token in an unusual encoding or a customer number your system invented will not match any known pattern.