Why a prompt is the wrong place for a secret

An AI assistant may need to understand an error message or a configuration problem, but it rarely needs the real password or API key involved. A secret pasted into a prompt becomes part of the conversation sent to the service. Depending on the product and its settings, that conversation may also appear in chat history, administrative tools or other records. You should not assume that closing a tab or deleting a visible message removes every copy.

The risk is not limited to deliberately typed credentials. A copied terminal output may contain a token in a command, an authorization header or a connection string. Screenshots can show passwords or recovery codes in the background. A document uploaded for summarization may include an access link. Treat anything you attach, paste or let a tool read as potential prompt content, and check it before sending.

Know what to remove

Passwords and API keys are obvious examples, but secrets also include session cookies, access and refresh tokens, private keys, database connection strings, recovery codes and authentication links. A string does not have to look like a password to grant access. For example, a URL with a token in its query parameters may work for anyone who has it. Configuration files and log excerpts deserve particular care because they often mix useful diagnostic details with credentials.

Also consider information that could help someone use a credential, such as an account name, project identifier or internal service address. Those details are not always secret on their own, and you may need some of them to explain a problem. Share only what the task requires. If you cannot tell whether a value grants access, leave it out while you investigate.

Build a useful prompt without real credentials

Replace each secret with a clear placeholder before asking for help. For instance, show API_KEY=[REDACTED_API_KEY] in a configuration example rather than the working key. Keep enough structure to explain the issue: the variable name, whether a value is missing, and the location in a request where it belongs may matter. The actual value usually does not. If a full error message contains a secret, copy it into a temporary note, remove the value, then review the edited version before pasting it.

You can ask an assistant to explain how to pass a credential through an environment variable or a secret-management tool without supplying that credential. For a code example, request a placeholder and add the real value only in your own approved environment. Do not ask an AI tool to generate a realistic-looking key for testing if a simple dummy value will do; a clearly fake value is easier for everyone to recognize.

Make safe handling part of the workflow

A final glance at the prompt is helpful, but a repeatable process is better. Keep credentials in a password manager, secret manager or other storage appropriate to your work rather than in notes prepared for an AI chat. When sharing code, prepare a small example that reproduces the behavior without a live connection. Review file attachments, copied logs and screenshots as carefully as the words you type. If a team uses AI tools, agree on which tools may receive work material and who can review their settings.

Be cautious with features that read more than the current prompt, such as connected apps, repository access or automated workflows. Their usefulness depends on access to other material, which may include secrets you did not intend to share. Limit access to what the task needs and check what a tool will read or transmit before enabling it. Privacy controls and retention settings can reduce some exposure, but they are not a substitute for keeping credentials out of the input.

If a secret slips into a chat

Treat an accidentally shared credential as potentially exposed. Where you have the authority to do so, revoke or rotate it promptly, then update the systems that depend on it. If it is a work credential, follow your team’s incident process or tell the person responsible for access. A password may also need changing anywhere it was reused. For an API key or token, check the relevant service’s available activity records for unexpected use; an absence of visible activity does not prove that no one saw it.

After securing access, remove the message or attachment from the chat if the product allows it and review the provider’s available deletion or support options. Deletion can limit what remains visible, but it should not replace rotation. Finally, identify how the secret entered the prompt: a copied log, a screenshot, a connected tool or a rushed paste. Fixing that step makes the next request both safer and easier to write.

Back to category ↗