Where shared logs end up
- Public issues and forums are indexed by search engines and read by bots that look for keys.
- Vendor support tickets live in someone else's helpdesk, with their staff, retention and security.
- Team chat is searchable by everyone in the channel, including people who join later, and synced to phones.
- AI assistants store the conversation on the provider's servers.
Deleting the message later does not undo it. A copy may already sit in an email notification, a search index or a backup, and a leaked key keeps working until you revoke it.
What to remove
- Configuration printed at startup: environment variables, connection strings, API keys.
- HTTP debug output:
Authorizationheaders, cookies, tokens in query strings. - Private keys and certificates.
- Customer data in error messages: emails, IP addresses, card numbers, phone numbers.
- Internal details you may not want public: hostnames, account IDs, file paths with user names.
Example: a startup log before and after
Before highlights what PasteSafe finds. After is its exact output.
2026-09-15 09:41:07 INFO starting billing-api on db-prod.acme.internal with config:
DATABASE_URL=postgres://billing:Wint3r-Fake-Pass@db-prod.acme.internal:5432/billing
STRIPE_SECRET_KEY=sk_test_51FakeKeyForDocs0nlyNotReal0000
AWS_ACCESS_KEY_ID=AKIA2EXAMPLE7FAKEKEY
SENTRY_ENVIRONMENT=production
2026-09-15 09:41:09 DEBUG POST https://api.example.com/v1/charges
Authorization: Bearer FakeBearer7fK2mZpL9wR3nB8vT1yCq
Cookie: sessionid=9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c; theme=dark
2026-09-15 09:41:09 ERROR 402 card_declined for ops@example.net from 198.51.100.72026-09-15 09:41:07 INFO starting billing-api on db-prod.acme.internal with config:
DATABASE_URL=postgres://billing:DB_PASSWORD_1@db-prod.acme.internal:5432/billing
STRIPE_SECRET_KEY=STRIPE_KEY_1
AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY_1
SENTRY_ENVIRONMENT=production
2026-09-15 09:41:09 DEBUG POST https://api.example.com/v1/charges
Authorization: Bearer BEARER_TOKEN_1
Cookie: sessionid=9f8a7b6c5d4e3f2a1b0c9d8e7f6a5b4c; theme=dark
2026-09-15 09:41:09 ERROR 402 card_declined for EMAIL_1 from IP_1The keys, the database password, the Bearer token, the email and the client IP are replaced. The internal hostname and the session cookie are not: PasteSafe does not treat hostnames as secret, and a sessionid cookie with a hex value, sent together with other cookies, matches none of its rules. That is why the last step below is to read the result.
Step by step with PasteSafe
- Cut the log down to the part that matters.
grep -n -B 5 -A 30 ERROR app.logprints each error with 5 lines before it and 30 after. Less text means less to leak. - Paste it into PasteSafe or drop the file onto the editor.
- Look through the Findings list, which groups what was masked by type.
- Read the cleaned text and replace anything left by hand, like the hostname and cookie above.
- Press Copy cleaned text and paste it where it needs to go.
On the command line
gitleaks, the open source scanner whose rules PasteSafe uses, can check a log for known secret formats. It reports what it finds and does not change the file:
gitleaks dir -v app.log
cat app.log | gitleaks -v stdin
To replace values in a file, sed handles simple key=value cases:
sed -E 's/((password|secret|token|api_key)=)[^&[:space:]]+/\1REDACTED/g' app.log > app.clean.log
A pattern list like this only catches the names you wrote down. Run gitleaks on the cleaned file afterwards to see what is left, and read it anyway.
What PasteSafe does not catch
- Internal hostnames, account IDs and file paths.
- Session cookies in a
Cookieheader with several cookies, when the name ends in id, likesessionidorsession_id, or the value is plain hex. - Passwords typed as plain words in a message, and names or street addresses.
Questions
What does it mean to sanitize a log?
Sanitizing a log means removing or replacing the values that should not be shared, such as API keys, passwords, session tokens and personal data, while keeping enough context to debug the problem.
What should I remove from logs before posting a GitHub issue?
API keys, tokens, passwords, connection strings, cookies, private keys, customer emails, IP addresses and card numbers. Keep error messages, stack traces, versions and timestamps, since those are what maintainers need.
Can gitleaks redact secrets in a log file?
No. gitleaks finds secrets and reports them. Its --redact option hides the secret values in its own output, but the log file itself stays unchanged.
Is a sanitized log safe to post publicly?
Only after you have read it. Scanners catch known formats, but hostnames, names and plain passwords in free text can slip through. When in doubt, share it privately with the person who needs it.