OWASP LLM07

LLM07 System Prompt Leakage: Keep Secrets Out of Your Prompts

OWASP LLM Top 10 · 2025 edition · Updated 25 November 2026 · Independent educational guide

New to LLMs, classifiers or RAG? Read the beginner FAQ and terminology.

Building an action-taking agent? Read the full agent runtime security guide for execution-time boundaries, safe tests and OWASP mapping.

Read the dated field-test post.

What is system prompt leakage in LLM applications?

System prompt leakage occurs when users extract the hidden instructions given to a model. The real risk is not the wording but what it contains: credentials, internal rules or security logic. Assume any system prompt can be revealed, keep secrets out of it, and enforce controls in code rather than instructions.

Can users extract my system prompt?

Usually yes, with enough attempts. Techniques include asking the model to repeat its instructions, role-play, translation tricks and encoding requests. Filters can make extraction harder but not impossible. Design as if the full system prompt will eventually become public, and make sure nothing in it would cause harm if it did.

What should never go in a system prompt?

Never include API keys, passwords, database connection strings, internal URLs, other users' data, or permission rules you rely on for security. Authorisation decisions such as which records a user may see must be enforced by your application code and database policies, not by asking the model to behave.

How do I audit my app for OWASP LLM07?

Read every system prompt and remove secrets and sensitive internal detail. Identify any security rule expressed only as an instruction and move its enforcement into code. Then attempt common extraction prompts and confirm that even a full leak would expose nothing harmful.

What does this OWASP LLM risk look like in practice?

Illustrative scenario: An application stores a private service key inside instructions given to the model.

How can I test it safely?

Inspect prompt construction without publishing real secrets. Replace any credentials with server-side access controls. Test extraction using fictional markers and verify that revealing the entire prompt would not grant access or disclose private records.

What evidence should I keep?

Record removed sensitive fields and independently enforced permissions. A failed extraction attempt does not prove the prompt cannot leak.

LLM07 audit checklist

Control to consider: System prompt guard. Some controls run outside the request path; model inline checks, then measure your own deployment.

General guidance only, written with AI assistance and human oversight. Verify against your own system and the official OWASP project before relying on it.

Sources and scope

Examples and checklists are our explanatory guidance, not an official OWASP audit, endorsement or a test of your application. Calculator values are modelled assumptions, not detector benchmarks.

Other OWASP LLM risks