LearnThatStack Ace your next interview
AI Security & Guardrails · question
Question 3 of 55

Why can't prompt injection be fixed the way SQL injection was fixed with parameterized queries?

beginner
← All AI Security & Guardrails questions
Re-explain

Prompt injection has no parameterized-query fix because an LLM has no separate channel for instructions and data.

SQL injection was fixed because databases separate code from data. A prepared statement sends the query shape first and values after, so a value never becomes syntax.

An LLM has no such split. System prompt, user text, and retrieved documents arrive as one token sequence. Instructions are recognized by meaning, not position.

# SQL: the driver enforces the boundary
cur.execute("SELECT * FROM docs WHERE id = %s", (user_input,))

# LLM: the "boundary" is just more text
prompt = f"{system}\n\nDocument:\n{untrusted_doc}"

So defenses move outward: limit tools, permissions, and blast radius.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for AI Security & Guardrails One question at a time. Answer out loud, get graded, see what you missed.
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. There's no parameterized-query fix for prompt injection because an LLM has no separate channel for instructions and data.
  2. SQL injection got fixed because a prepared statement sends the query shape first and the values after, so the driver never lets a value turn into syntax.
  3. With an LLM, the system prompt, the user's message and any retrieved documents all arrive as one sequence of tokens.
  4. The model spots instructions by what the text means, not where it sits, so an order hidden in a retrieved document can still steer it.
  5. Wrapping untrusted text in delimiters doesn't give you a real boundary either, because the delimiter is just more text.
  6. Since I can't stop injection inside the model, I limit what it can reach, meaning fewer tools, tighter permissions, and a small blast radius when an injection lands.

Weak answers to avoid

  • Says a stronger system prompt or delimiters will fix it Any instruction or delimiter is more text the model interprets by meaning. Say it lowers risk at best, then move to limiting tools and permissions.
  • Thinks input filtering works like SQL escaping Escaping works because SQL has a fixed grammar. Natural language has nothing to escape against, and a paraphrase slips past the filter.
  • Explains SQL injection but never the LLM contrast The question is the contrast. Name what's missing: no separate channel, one token stream, and instructions recognized by meaning.
  • Stops at 'it can't be fixed' with no defenses It sounds defeatist. Finish with what you'd do: least privilege on tools, scoped permissions, and a small blast radius when an injection gets through.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the AI Security & Guardrails cheatsheet.

← Back to all AI Security & Guardrails questions
Pro · $10/mo

48 of 55 AI Security & Guardrails answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime