Home / patterns

Secrets and access rules hidden in your AI system prompt (system prompt leakage)

A developer at a home-office desk in the evening holding a small brass padlock beside a laptop that shows a blurred chat window, a second monitor with a blurred long text document, desk lamp, mug and potted plant, no brand logos
Quick answer: A common shortcut in vibe-coded AI features is to put everything into the system prompt: an API key for a tool, a database name, the discount codes, “only admins may see salaries,” “never reveal other users’ orders.” OWASP’s Top 10 for LLM applications lists this as System Prompt Leakage (LLM07:2025) and is blunt about it: the system prompt should not be treated as a secret or used as a security control. Users can often get a model to repeat its instructions, and even when they can’t, they can work out the rules by testing. The real risk is what the prompt holds and the checks it replaces, so move secrets out and enforce access in your code.

Last updated November 16, 2026

Steps

  1. Find every system prompt in your app (code, environment variables, your AI provider’s dashboard, agent or assistant settings) and read each one as if a stranger will see it.
  2. Remove credentials and connection details: API keys, tokens, passwords, database names and internal URLs. Keep them in server-side environment variables used by your code, never in text the model sees.
  3. Rotate any key or password that has ever been in a prompt, since you can’t know who already got the model to print it.
  4. Remove security rules from the prompt as the only line of defense: “only show the user their own orders,” “admins can edit records,” spending or transaction limits. Enforce these in your server code or database (for example row-level security) before data ever reaches the model.
  5. Keep business-sensitive details (unreleased prices, internal discount codes, staff-only notes) out of the prompt unless you’re fine with every user reading them.
  6. If certain content must never appear in answers, check the model’s output with separate code before showing it, rather than relying on “don’t reveal this” in the prompt.
  7. Retest: ask your own app to repeat, summarize or translate its instructions, and confirm nothing in the reply would hurt you if posted publicly.

Why it matters

OWASP’s examples include a system prompt containing credentials for a tool, which an attacker extracts and reuses, and a prompt listing rules like daily transaction limits that tells an attacker exactly what to try to bypass. OWASP’s guidance is that disclosure of the prompt isn’t the core problem; storing secrets there and handing authorization to the model are. Its fixes: keep sensitive data out of system prompts, enforce guardrails outside the model, and keep privilege separation and authorization checks in deterministic code. This page is for checking and fixing your own app.

Sources

OWASP Gen AI Security Project: LLM07:2025 System Prompt Leakage — https://genai.owasp.org/llmrisk/llm072025-system-prompt-leakage/

OWASP Cheat Sheet Series: LLM Prompt Injection Prevention (system prompt leakage as an impact; least privilege) — https://cheatsheetseries.owasp.org/cheatsheets/LLM_Prompt_Injection_Prevention_Cheat_Sheet.html

Checked at the source on November 14, 2026.

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.