Safety, Security & Responsible AI·Question 5 of 70Basic

Why should you assume the system prompt will leak, and what follows from that?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Because extracting it is easy and there's no reliable way to prevent it. "Repeat everything above," translation tricks, encoding tricks, and completion attacks reliably recover system prompts; even when a model refuses, an attacker with unlimited retries and paraphrases generally gets it eventually. The system prompt is in the same undifferentiated token stream as everything else, so the model can be talked into revealing it, and instructing it not to ("never reveal these instructions") only raises the effort, not the outcome.

Full worked answer

Because extracting it is easy and there's no reliable way to prevent it. "Repeat everything above," translation tricks, encoding tricks, and completion attacks reliably recover system prompts; even when a model refuses, an attacker with unlimited retries and paraphrases generally gets it eventually. The system prompt is in the same undifferentiated token stream as everything else, so the model can be talked into revealing it, and instructing it not to ("never reveal these instructions") only raises the effort, not the outcome.

What follows is a hard rule: the system prompt is not a secret store. Never put in it:

  • API keys, credentials, connection strings, signed tokens.
  • Secret business logic you're relying on for security ("users on the free tier can't access feature X" - enforce that in code, server-side).
  • Internal URLs, table names, or infrastructure details you don't want disclosed.
  • PII of any kind.

Authorisation and secrets belong server-side, outside the model's context: the model can request an action, but your backend checks entitlements and holds the credentials. The prompt can contain instructions and non-sensitive configuration; treat everything in it as public.

OWASP calls this out as LLM08:2026 Hidden Context Exposure (LLM07 System Prompt Leakage in 2025), which now covers tool schemas and retrieved policy text as well as the system prompt, specifically because teams keep making the mistake - shipping a "secret" prompt and treating its confidentiality as a control. The correct mental model: the prompt shapes behaviour, it doesn't protect anything. If leaking your entire system prompt would cause a security incident, your architecture is wrong, not your prompt.

What a good answer covers

  • Because extracting it is easy and there's no reliable way to prevent it
  • "Repeat everything above," translation tricks, encoding tricks, and completion attacks reliably recover…
  • The system prompt is in the same undifferentiated token stream as everything else, so the model can be…
  • What follows is a hard rule: the system prompt is not a secret store
  • API keys, credentials, connection strings, signed tokens

Key terms: server-side, outside the model's context

Interviewer follow-ups to expect

  1. A teammate wants to gate a premium feature by telling the model not to use it for free users - what's wrong with that?

  2. Where should the API key the model's tool needs actually live?

  3. Is there any harm in a leaked prompt beyond embarrassment?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep