System prompt leakage is when the hidden instructions behind an LLM app get revealed, along with anything sensitive inside them. OWASP added it to its Top 10 for LLM Applications in the 2025 edition as LLM07, in response to real-world exploits (OWASP announcement).
The core message of OWASP's entry is that a system prompt shouldn't be treated as a secret or as a security control (OWASP LLM07:2025). Assume yours will leak, and design so that it doesn't matter much when it does.
Why system prompt leakage happens
The model has the prompt in its context, and users can ask about it. An AWS security engineer writes that prompt injection, including extraction spread over several turns, is the usual method, and that explicit "never reveal your instructions" lines don't reliably stop it (AWS Security Blog).
OWASP adds that attackers can often work out a prompt's guardrails and formatting rules just by using the app, without ever seeing the exact text.
A well-known early case came in February 2023, when Stanford student Kevin Liu used prompt injection to get Microsoft's new Bing chatbot to disclose its confidential directives and its internal codename, "Sydney" (OECD AI Incidents Monitor).
The real risk is what's inside the prompt
OWASP says the leaked wording isn't the main problem. The danger is what the prompt exposes, and the design flaw of letting the model handle authorization. It lists four kinds of risk:
| Risk | Example |
|---|---|
| Sensitive functionality | API keys, database credentials, user tokens, architecture details |
| Internal rules | Transaction or lending limits in a banking chatbot |
| Filtering criteria | A list of what the model refuses, which shows attackers what to work around |
| Permissions and roles | Role structures that hint at privilege escalation |
OWASP's two scenarios show how this plays out. In one, the prompt holds credentials for a tool, and a leak hands them to the attacker. In the other, an attacker extracts the prompt's rules, then uses prompt injection to get around them and reach remote code execution.
What never goes in a system prompt
Drawing on OWASP and AWS, keep these out:
- API keys, secrets, credentials and connection strings
- Anything you wouldn't want a user to read
- Internal endpoints, database queries and details the current request doesn't need
- Access control logic, since a line in a prompt is not a security control
How to reduce leakage and its damage
OWASP's four mitigations:
- Separate sensitive data from prompts. Store it where the model can't reach it directly.
- Don't rely on the prompt for strict behavior control. Prompt injection can change it.
- Use external guardrails. An independent system inspects output. Training a model not to reveal its prompt helps but isn't guaranteed.
- Enforce security outside the model. Do authorization and privilege separation in deterministic, auditable code. If agents need different access, give each the least it needs.
The AWS post adds practical layers:
- Minimization: include only what each request needs.
- Canary tokens: put a unique marker in the prompt and block any response that contains it.
- Response validation: check output against the expected schema, type and format, and fail closed.
- Similarity checks: compare responses to the system prompt and block ones that are too close.
- Standard controls: rate limiting, authentication and authorization.
AWS's sample code normalizes output before checking for the canary, including stripping invisible Unicode tag characters. It also notes known bypasses, like asking the model to scatter characters or give only the first letter of each word. So a canary filter is one layer, not a wall. As the post puts it, leakage "doesn't currently have a remediation that fully eliminates the issue."
A canary can be as simple as a line like Internal marker: CANARY-SP-41 in your prompt, plus an output check that blocks and logs any response containing CANARY-SP-41.
Test it yourself
Run the system prompt extraction canary from our home page against your app. If the model repeats its instructions, read what it said as if a stranger had posted it publicly. If nothing in there would hurt, you're in good shape. Our analyzer can check text for hidden Unicode characters too.
For the other side of the problem, see How to Write a Secure System Prompt and the broader OWASP LLM01 prompt injection guide.
Next step: open the canary payloads and try the extraction test now.