Boundaries of prompt safety
Injection attacks exploit the blurred boundary between data and instructions — separation, guardrails, and least privilege each block a layer, each with costs and failure modes.
Prompt effect has not been tested.
A prompt is a re-runnable template, not a promise of results. Changing the model, version or input can change the outcome. Use the checkpoints on this page to verify it yourself, and treat the official sources as evidence of mechanism rather than a guarantee of effect.
What this guide covers
The core problem of prompt safety: the model cannot tell instructions from data. The paper's one-line summary: LLM-integrated applications "blur the line between data and instructions". An attacker hides instructions inside data, and the model may simply comply. Defense comes in three layers: prompt-level separation, application-level guardrails, protocol-level least privilege. We have not run hands-on tests; the mechanisms below come from official docs, specs, and papers.
Injection: instructions hidden in data
The indirect prompt injection attack path (as defined by the paper): the attacker never touches the model directly — prompts are planted into data likely to be retrieved: web pages, documents, emails, waiting for the application to fetch them and feed them to the model. Demonstrated impacts include data theft, worming, and contamination of the information ecosystem; processing retrieved prompts can act like arbitrary code execution: manipulating application behavior and deciding whether and how other APIs get called. The paper's judgment at publication: effective mitigations were still lacking.
Prompt level: separate data from instructions
Anthropic's official tutorial approach: prompt templates with variable substitution, wrapping variable content in XML tags so the model knows where data begins and ends. The tutorial's counterexample: without tags, "Yo Claude" inside user input gets treated as part of the task. Separation makes it harder for injected text to cross the data boundary.
Two sobering notes: the official docs say Claude is trained to recognize XML tags, but there are no mandatory "magic tags"; separation is mitigation, not a guarantee — the attack surface the paper identifies does not disappear.
Guardrails: input and output
OpenAI's cookbook defines guardrails as detective controls on two sides: input side intercepts content before it reaches the model — off-topic queries, jailbreaks, prompt injection; output side validates results before they reach the user — hallucinations, policy violations, broken syntax. Guardrails can run in parallel with the main call, intercepting only when triggered, keeping latency down.
Thresholds are a trade-off, not mysticism: the official advice is to build an eval set and set tolerance with a confusion matrix. More false positives fracture the experience as legitimate requests get rejected; more false negatives let dangerous content through, and the business bears the consequences. Tolerance varies by scenario: high jailbreak risk calls for stricter thresholds.
Limits of guardrails
The official cookbook lists three limits, each one critical: an LLM guardrail shares the base call's vulnerabilities — one injection can evade both at once; the longer the conversation, the more instructions get diluted, and the easier jailbreaking becomes; overly strict guardrails over-refuse, misclassifying normal requests as attacks.
Official mitigations: combine with rule-based detection or traditional models; some guardrails consider only the latest message to avoid long-conversation confusion; roll out gradually with monitoring, feeding new attack samples back into the guardrails.
Protocol level: least privilege and consent
What prompts cannot stop, the protocol layer catches. The MCP security spec requires: scope minimization — start with a minimal set of low-risk baseline scopes, elevate incrementally when a privileged operation is first attempted, and avoid wildcard or omnibus scopes. The spec spells out the cost of broad scopes: a leaked token has a large blast radius, revocation disrupts every workflow, and audit trails obscure intent.
Proxy servers must obtain per-client user consent to prevent confused-deputy attacks; token passthrough (forwarding the client's token as-is to downstream APIs) is an explicitly forbidden anti-pattern. Tool-side permission design decides how far an attacker gets after a successful injection.
Failure modes
- Trusting retrieved content: treating fetched pages and documents as trusted instruction sources puts injection straight into context.
- Single-layer illusion: assuming one guardrail is enough, forgetting it shares vulnerabilities with the main call.
- Over-refusal: tightening guardrails against injection until normal requests are rejected at scale.
- Granting everything up front: one leaked token hands over every capability, and revocation forces re-consent across the board.
- Long-conversation complacency: more turns dilute instructions further — monitoring must keep pace.
The shared logic of all three layers: accept that the model can be fooled, and contain the damage within each layer's boundary.
Sources
- OpenAI Cookbook · How to use guardrails
- Anthropic official tutorial · Separating Data and Instructions
- Indirect Prompt Injection (arXiv 2302.12173)
- MCP specification · Security Best Practices
Verified 2026-11-07; all four fetched directly with HTTP 200. The OpenAI and Anthropic doc sites were unreachable from this network; official content was taken from raw files in both vendors' official repositories.
Sources
| Source | URL |
|---|---|
| OpenAI Cookbook · How to use guardrails (official repo raw file, direct fetch 200 on 2026-11-07) | https://raw.githubusercontent.com/openai/openai-cookbook/main/examples/How_to_use_guardrails.ipynb |
| Anthropic official tutorial · Separating Data and Instructions (official repo raw file, direct fetch 200 on 2026-11-07) | https://raw.githubusercontent.com/anthropics/courses/master/prompt_engineering_interactive_tutorial/Anthropic%201P/04_Separating_Data_and_Instructions.ipynb |
| Indirect Prompt Injection paper (arXiv 2302.12173, abstract page direct-fetched 2026-11-07) | https://arxiv.org/abs/2302.12173 |
| MCP specification · Security Best Practices (direct fetch 200 on 2026-11-07) | https://modelcontextprotocol.io/specification/2025-06-18/basic/security_best_practices |
Source snapshot: 2026-11-07; item-specific rechecks and their scope are recorded in the text or source notes. Features and terms may change; check the original sources before use.