Why secrets end up in AI chats
Debugging with an AI assistant usually starts with "here's the error". The error rarely comes alone. A failed HTTP call logs its Authorization header. An ORM error prints the full DATABASE_URL, password included. A crash dump includes the environment. Copy the whole thing into a chat window and every one of those values now sits in a third-party service's history.
Once a secret has left your machine you can't pull it back. Chat history may be retained, reviewed for abuse or, depending on your plan and settings, used to improve models. The only safe assumption is that a pasted key is a leaked key.
What the tool catches on this page
| Secret | Example | Becomes |
|---|---|---|
| Provider API keys | sk-proj-…, sk-ant-…, AKIA…, ghp_…, xoxb-…, AIza… | [API_KEY_n] |
| JWTs | eyJhbGciOi… | [API_KEY_n] |
| Bearer tokens | Authorization: Bearer 9f8e… | Bearer [SECRET_n] |
| Labeled secrets | password=…, "client_secret": "…", smtp_password: … | password=[SECRET_n] |
| Connection-string passwords | postgres://app:Tr0ub4dor@db:5432 | postgres://app:[SECRET_n]@db:5432 |
| User data in log lines | emails, IPv4/IPv6 addresses | [EMAIL_n], [IP_n] |
Known key formats become [API_KEY_n]; secrets recognized by their label or position become [SECRET_n]. The number n counts up in order of appearance. Placeholders also stay consistent. If the same token appears in ten log lines, it's [SECRET_1] all ten times, so the AI can still see that the same credential is involved everywhere.
Step by step
- Trim first. Paste the failing request and the trace, not 5,000 lines of log. Less text means fewer chances for something to slip through, and a better answer.
- Paste into the tool above and read the right pane. Highlighted values were replaced.
- Add what patterns can't know. Internal hostnames (
db.internal.acme.io), customer names, project code names, and account IDs in your own format go in as custom terms. They're saved in your browser for next time. - Copy the masked text into ChatGPT, Claude or your coding assistant and ask your question.
- Restore if needed. If the AI suggests a fixed config or command, paste it into Restore in the full tool to put your real values back before you run it.
Before and after
An excerpt of the tool's actual output for the sample above. Click Load sample to see the full version.
Authorization: Bearer 9f8e7d6c5b4a39281706f5e4d3c2b1a0ffee1234
DATABASE_URL=postgres://app_user:Tr0ub4dor-3x@db.internal.example-shop.io:5432/orders
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
config.yaml: smtp_password: "hunter2-prod-2026"
Authorization: Bearer [SECRET_1]
DATABASE_URL=postgres://app_user:[SECRET_2]@db.internal.[COMPANY_1]:5432/orders
AWS_ACCESS_KEY_ID=[API_KEY_1]
config.yaml: smtp_password: "[SECRET_3]"
The structure the AI needs is intact: it's a Postgres URL, the header is a bearer token, the AWS key ID is present. Only the values are gone.
If you already pasted a key
- Rotate it now. Revoke the key at the provider and issue a new one. Deleting the chat doesn't un-leak it.
- Check usage. Look at the provider's billing and access logs for calls you don't recognize.
- Look for copies. The same value may sit in shared chats, tickets or screenshots.
- Prevent the next one. Keep secrets in a secret manager rather than
.envfiles you copy around, and add a pre-commit secret scanner to your repositories.
Limits
- Unlabeled random strings in formats the tool doesn't know (a custom token with no
key=in front) can slip through. Read the output. - Private keys and certificates (
-----BEGIN … PRIVATE KEY-----blocks) should not be pasted at all. Delete them from the text. - Source code can be confidential too. Masking secrets doesn't make proprietary code shareable if your employer says it isn't.
FAQ
Is it safe to paste a stack trace into an AI chatbot?
Usually, once secrets, customer data and internal hostnames are out. Function names and line numbers are rarely sensitive. Tokens in headers, credentials in URLs and user emails in log lines are.
Does the AI still understand the error with placeholders?
Yes. Debugging depends on the shape of the request, the error message and the code path, not on the literal key. Tell the AI the placeholders are intentional; the tool's default instruction already does.
Is the tool itself safe to paste secrets into?
The tool frame runs under a Content Security Policy of connect-src 'none', so the browser blocks every network request it tries to make. Your text and the mapping stay in that tab's memory. Open DevTools → Network while you paste to check.
Where to go next
- Open the full tool: restore the AI's fixed config with your real values, export the mapping, and save internal hostnames as custom terms.
- Prompt templates: includes one for debugging a log or stack trace, set up to keep placeholders intact.
- GDPR pseudonymization for LLM prompts: when your logs contain EU customers' emails and IP addresses.
- How to anonymize patient data for ChatGPT: for health-tech teams whose logs touch patient records.