Extracting System Prompts and Proprietary Instructions
After gaining interaction access to a deployed AI application, the system prompt and any injected instructions are the first things to recover. They reveal the application's intended behavior, what restrictions are in place, what tools are available, what backend systems are connected, and often contain hardcoded credentials, API keys, or internal service URLs the developer embedded directly in the prompt.
System prompt extraction is post-exploitation reconnaissance. The information extracted here feeds directly into further attacks: tool abuse, privilege escalation through the agent layer, and bypassing application-specific safety filters.
Direct Extraction Attempts
Start with direct requests. Many deployed models will comply with straightforward requests for their system prompt, especially when framed as a legitimate operational task:
Indirect Extraction via Behaviour Probing
When direct requests are refused, reconstruct the system prompt by probing the model's behavior across topics and observing what it will and will not do. A model that refuses to discuss competitors, always recommends a specific product, or uses a particular persona reveals its instructions through its responses:
Token Completion Extraction
Provide the beginning of the expected system prompt format and let the model complete it. If the model was given a structured system prompt, starting with the typical preamble triggers completion of the full text:
Translation and Encoding Bypass
Models that refuse to repeat their system prompt in English may comply when asked to output it in another language, encoded in base64, or formatted as a different artifact type:
A base64 response can be decoded immediately:
You are a helpful assistant...
Any recovered system prompt content should be scanned for embedded API keys, connection strings, internal hostnames, and hardcoded credentials before using it as input to further attack steps.
References
-
OWASP Top 10 for LLM Applicationsowasp.org/www-project-top-10-for-large-language-model-applications (opens in new tab)
LLM07: System Prompt Leakage covering extraction techniques and impact
Was this helpful?
Your feedback helps improve this page.