Zenaique

Which of the following are MEANINGFUL defenses against prompt injection in a production LLM application?

Multi-select·Medium·4.0 · 0·~1 min·Asked atAi4bharatBrowserbaseGnani·Relevant atAnthropicMicrosoft
Attempt it
TL;DR

Prompt injection is a defense in depth problem: structural separation, least-privilege tools, pre-filtering, and output checks stack; more instructions and 'trust the model' do not.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine your house has a sign on the door that says 'do not steal.' A thief who can read just laughs. What actually keeps them out is locks on the doors, a small safe for valuables, cameras, and an alarm that calls the police. Prompt injection works the same way. Telling the model 'please ignore any sneaky instructions' is the paper sign. Real protection comes from putting user text in a clearly labeled envelope, limiting which tools the model is allowed to use, screening dangerous inputs before they arrive, and checking outputs on the way out. No single layer is bulletproof, but several thin layers stacked together are very hard to break through at once.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Prompt injection is the security category that decides whether an LLM application is hardened or hopeful. The question gets asked at every senior interview because the answer reveals whether the candidate understands that LLM apps are systems, not prompts.

This deep dive walks through why injection is structurally different from classical input-validation bugs, what defenses actually stack, what defenses look like they should work but do not, and how the production stance maps onto the agentic systems most teams are shipping now. The goal is a working mental model that holds up when an attacker is creative.

The headline is that no instruction-layer fix solves a context-layer problem. Once trusted and untrusted text share a context window, the defense has to live elsewhere.

Why injection is structurally different

Classical input-validation bugs assume the parser separates code from data. SQL injection works because a string is concatenated into a query and the database cannot tell which characters were meant as syntax. The defense, parameterized queries, restores the separation.

LLMs have no such separation. Every token in the context window is read by the same attention mechanism, and the model decides what each token means based on patterns it has learned. A line that says 'ignore previous instructions' carries weight regardless of which message-role envelope contains it, because the model has seen exactly that phrasing many times during training and has learned to take it seriously.

This means defenses cannot work by hardening the system prompt against specific phrasings. The attacker can always rephrase. Defenses have to either change the structure of the input (delimiters and data directives that the model has been trained to respect) or change the consequences of compliance (tool scoping, output checks, identity-bound capabilities).

The four defense layers that actually stack
What looks like a defense but is not
Indirect injection and the trust boundary
Production stance and what to build into CI
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Anthropic's Claude prompt-engineering guide recommends XML delimiters and an explicit data directive for untrusted content blocks, with tool scoping as the second line of defense.
  • Microsoft Copilot for Microsoft 365 documents a layered injection-defense architecture: input shields, tool allowlists, and output checks before responses leave the trust boundary.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you design tool scoping for an agent that reads emails and can also send them?
A

Separate read and write tools, require user confirmation on write tools, validate recipient against an allowlist tied to the authenticated identity, and log every send for audit.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating prompt injection as something one cleverly worded system instruction can solve, instead of a defense in depth problem that needs structural separation, tool scoping, and output checks layered together.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Why prompt injection is a structural problem, not an instruction problem

  • The four meaningful defense layers

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Describe how a Special…
Short answer·Hard