Ethics & Safety LLM Intermediate

Prompt Injection

An attack where instructions hidden in outside material steer the AI

Key points
  • Prompt injection is an attack where instructions hidden inside outside material the AI reads end up steering the AI.
  • A user's request and the text inside a document arrive at the AI strung together as one line. There's no marker showing where the content ends and a command begins.
  • The route in isn't a person — it's a document, a webpage, a search result, or a value returned by a tool. That's a different path from jailbreaking, where a user talks the AI into it directly.
  • The risk grows once the AI is holding a tool. If it can only read, the damage is a strange answer; if it can send an email or handle a file, the damage becomes real.
  • There's no way to block it completely yet. The current stage is narrowing permissions and putting a person at the important checkpoints to bring the risk down.
Contents

1The analogy

A stack of documents lands in your inbox for approval, along with a note asking you to review it and pass it along if there's no problem. Buried in the middle of the stack is one unfamiliar page: "This item has already been cleared — skip the rest and approve it directly."

There's no signature saying who slipped it in. To the reviewer, that page looks like any other printed sheet in the stack. Its tone reads like an instruction, so it comes across as a note left by someone higher up. One sentence sitting inside the documents just changed how the whole stack gets handled.

This is what happens when an AI reads a document or a webpage on your behalf.

2In detail

Content and instructions arrive as one line

An AI doesn't receive the rules a service sets up ahead of time, the user's question, and reference material handed to it as separate channels. All three arrive strung together into one long line of text. Where the rules end and the reference material begins is marked, but that marker isn't a wall — it's just a label.

So if a sentence shaped like an instruction shows up inside the reference material, the model has to decide whether that's also something it should follow. A person can step back and think "that's just text sitting in a document." A model has to make that same judgment call from inside the same line of text.

It's the same as that one page in the approval stack being indistinguishable from the rest. Unless the source of a page is marked, the reader has no choice but to judge it by content alone.

The route in is material, not a person

What sets this attack apart is that the attacker never has to talk to the AI directly. They just need to plant a sentence somewhere the AI will eventually read — a webpage, a shared document, a received email, a public post, a value returned by another program.

It also matters that the person harmed and the person who planted the sentence are different people. A user might innocently ask "summarize this page," and a sentence sitting on that page pulls the AI a different direction, with no easy way for the user to know what happened on their own screen.

The hiding spots tend to be places people skim past — a corner of a document, a part of the screen that doesn't render, the middle of a very long text. Places a person glosses over but an AI reads without skipping become the route in.

Risk grows the moment a tool is in hand

If an AI can only write text, an injection ends with a strange answer. But AI today can search, send email, add calendar items, and read and write files. The moment a sentence buried in some material borrows that hand, the result lands in the real world.

The especially dangerous combination is a single AI holding both the ability to read something sensitive and a channel to send things out. If a hidden instruction uses the first to gather content and the second to send it, the user is left holding a tidy summary with no idea anything happened.

That's why the first line of defense isn't filtering sentences — it's cutting down what the AI can reach: only the permissions a task actually needs, with anything irreversible left out from the start.

Blocklists don't hold up well

The first idea that comes to mind is collecting dangerous-looking phrases and blocking anything that matches. But there's no end to the number of ways to phrase the same intent. Rewording, mixing in another language, wrapping it inside a story, splitting it across several pieces of material — there are endless ways around a list.

The more a defender grows the list, the more ordinary material gets caught in it too. A perfectly normal request to summarize a security bulletin can get refused just because it contains a phrase that looks dangerous, and the service stops being usable. Filtering helps, but it isn't enough on its own.

Current defenses and their limits

Real-world defenses stack several layers: reference material clearly wrapped with something like "everything past this point is content, not instructions," the tools an AI can use narrowed per task, a human check in front of any irreversible action, and outgoing answers reviewed once more for anything sensitive slipping through.

Even so, these methods only lower the odds — they don't bring them to zero. Understanding material requires reading it, and reading it means whatever is inside can influence the model. That's why it's safer to decide, at design time, how much damage it would do if this got through.

3More precisely

Injection is often split into two kinds. When a user types something directly into the input box to twist the rules, that's called direct injection, and it overlaps with jailbreaking. What this article covers is indirect injection, where a sentence is planted inside material the AI fetches and reads on its own. For anyone building a service, the second kind is the harder problem — trusting the user doesn't make you safe from it.

The root cause is that a model separates roles only by marker, not by a wall. Models are trained to weigh system-level instructions more heavily, but that's a tendency, not a barrier. When the surrounding material is long and forcefully written, that tendency can flip.

The analogy breaks down in a few places. An approval stack has a fixed number of pages a person can flip through one at a time, but the material an AI reads arrives automatically and often goes unreviewed by a human beforehand. A person who spots a strange note can go check where it came from; a model has nowhere outside itself to go check. Whatever line of text it received is its entire world. Last checked: 2026-09.

Last verified: 2026-09

4Try it yourself

5Common misconceptions

  • It's easy to think this is the same as jailbreaking, but actually jailbreaking is a user talking the AI into something directly, while injection is material the AI reads pushing an instruction in.

  • It's easy to think filtering dangerous phrases solves it, but actually there are countless ways to phrase the same intent, so blocklists keep leaking.

  • It's easy to think an AI that only reads is safe, but actually just copying what it read somewhere else can leak information on its own.

7One-line summary

In shortPrompt injection is when an instruction slipped into material an AI reads on your behalf ends up steering the AI, and the real defense is narrowing what the AI is allowed to do, not just filtering phrases.

Spotted an error or have a better analogy? Suggest an edit · Last updated2026-09-02