---
title: "Prompt Injection, Explained: Why Your Agent Can't Tell Your Instructions From a Web Page's"
author: "Ecem Karaman"
source: "https://aiwithecem.com/guides/prompt-injection"
published: 2026-11-21
tools: ["Claude","ChatGPT","Multi-Tool"]
topics: ["Security","AI Agents"]
---

# Prompt Injection, Explained: Why Your Agent Can't Tell Your Instructions From a Web Page's

When you ask an AI to read a web page, an email or a file, everything in it lands in the same place as your request. If that content contains instructions, the model might follow them. That's prompt injection, and it matters more every time you give an AI access to your inbox, your files or your browser. Below is where it gets in, the small hidden tricks to watch for, and the settings that keep one bad instruction from doing real damage.

**Details checked against [OWASP's LLM01:2025](https://genai.owasp.org/llmrisk/llm01-prompt-injection/), [Anthropic's research](https://www.anthropic.com/research/prompt-injection-defenses), [OpenAI's guidance](https://openai.com/index/prompt-injections/) and [Claude Code's security docs](https://code.claude.com/docs/en/security) on November 21, 2026.**

> **In this guide**
>
> 1. [What it is](#what-it-is)
> 2. [Where it gets in](#where-it-gets-in)
> 3. [Why the model can't just filter it out](#why-the-model-cant-just-filter-it-out)
> 4. [The combination to avoid](#the-combination-to-avoid)
> 5. [Small hidden details to watch for](#small-hidden-details-to-watch-for)
> 6. [Settings that limit the damage](#settings-that-limit-the-damage)
> 7. [Before you connect anything](#before-you-connect-anything)

## What it is

Prompt injection is any input that changes what the model does in ways you didn't intend. [OWASP](https://genai.owasp.org/llmrisk/llm01-prompt-injection/) splits it in two:

- **Direct:** someone types it into the chat. This overlaps with jailbreaking.
- **Indirect:** it rides in on content the AI reads for you, like a website or a file. This is the one to watch, because you usually never see it.

[OpenAI's example](https://openai.com/index/prompt-injections/): you ask an agent to reply to your overnight emails, and an attacker's email tricks it into finding your bank statements and sharing them.

## Where it gets in

| Source | What it looks like | What it can push the agent to do |
| ------ | ------------------ | -------------------------------- |
| **Web pages** | A line in a listing or review, often hidden from view | Recommend that listing no matter what you asked for |
| **Emails and shared docs** | A message that claims to be urgent or official | Delete, forward or share things you didn't mention |
| **Project files** | A rules file, README or code comment | Add code you never asked for, without saying so |
| **Tools and MCP servers** | A tool description or result you never read | Read local files and pass them along |
| **Images** | Instructions inside a picture next to normal text | The same things text can |

The project-file row isn't hypothetical: researchers showed hidden instructions in a [rules file](https://www.pillar.security/blog/new-vulnerability-in-github-copilot-and-cursor-how-hackers-can-weaponize-code-agents) getting Cursor's agent to add a malicious script to generated HTML without mentioning it in chat.

## Why the model can't just filter it out

To a model, your request and the page it's reading are all text in the same context window. Providers train models to treat outside content as data, not commands, and scan that content for likely injections. It helps a lot, but it isn't a guarantee.

In Anthropic's own adaptive testing of a browser agent (November 2025), attacks against Claude Opus 4.5 still succeeded about 1.4% of the time with its improved safeguards, and Anthropic says even [1% "still represents meaningful risk"](https://www.anthropic.com/research/prompt-injection-defenses). OpenAI says prompt injection is [unlikely to ever be fully "solved"](https://openai.com/index/hardening-atlas-against-prompt-injection). So assume one will eventually get through, and limit what it can do when it does.

## The combination to avoid

Simon Willison calls it the [lethal trifecta](https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/). An agent becomes easy to exploit when it has all three:

1. **Access to your private data:** your inbox, files, notes, accounts.
2. **Exposure to untrusted content:** anything an attacker could have written, like web pages, incoming email or a third-party tool.
3. **A way to send data out:** sending an email, calling an API, or even loading an image or showing a link.

That third one is sneakier than it looks. A link or image URL can carry your data to someone else's server just by loading. OWASP describes a page whose hidden instructions make the model insert exactly that kind of image. **Remove one of the three** and an injection has far less to work with.

## Small hidden details to watch for

[OWASP](https://genai.owasp.org/llmrisk/llm01-prompt-injection/) puts it plainly: an injection doesn't need to be visible to humans, only readable by the model. These are the details that slip past a quick look.

| Detail | Why it's sneaky | What to do |
| ------ | --------------- | ---------- |
| **Zero-width characters** (zero-width space and joiners, word joiner, byte-order mark) | Take up no space, so they can hide inside normal text | Scan pasted prompts, templates and rules files |
| **Unicode tag characters** (U+E0000 to U+E007F) | Mirror ordinary letters but [show nothing on screen](https://en.wikipedia.org/wiki/Tags_(Unicode_block)), while the model can still read them | Same scan, especially before pasting a prompt you found online |
| **Direction markers** (right-to-left overrides) | Make text display in a different order than it's stored | Same scan, and read config files in an editor, not a rendered preview |
| **Invisible page text** | White on white, tiny fonts, HTML comments or alt text | Give the agent a specific task, not "do whatever this page says" |
| **Instructions in images** | Text inside a screenshot or graphic | Treat images from unknown sources like any other untrusted content |
| **Tool descriptions** | An MCP server's descriptions are read by the model, and the server can [change them after you approve it](https://invariantlabs.ai/blog/mcp-security-notification-tool-poisoning-attacks) | Install servers from sources you trust and recheck them after updates |
| **Links and images in answers** | A URL can carry data out the moment it loads | Look at where a link points before you click |

To check a file for hidden characters on a Mac or Linux, run this in a terminal from the folder that holds it:

```text
perl -CSD -ne 'print "$ARGV:$.: hidden character\n" if /[\x{200B}-\x{200F}\x{202A}-\x{202E}\x{2060}-\x{2064}\x{FEFF}\x{E0000}-\x{E007F}]/; close ARGV if eof' *.md
```

It prints the file and line of each hit. Change `*.md` to the files you want to check. A hit means look closer, not proof of an attack: some emoji, flags and languages use these characters for good reasons. More on hidden characters in [how watermark removers work](/guides/how-watermark-removers-work).

## Settings that limit the damage

- **Claude connectors:** set reads to **Always allow**, anything that sends, edits or deletes to **Needs approval**, and actions you never want to **Blocked**. Full walkthrough in [Claude Connectors](/guides/claude-connectors).
- **Claude in Chrome:** grant access site by site. Claude asks before publishing, purchasing or sharing personal data, and [high-risk site categories](https://claude.com/blog/claude-for-chrome) like financial services are blocked.
- **ChatGPT agent and Atlas:** use **logged-out mode** when a task doesn't need your accounts. The agent asks for confirmation before steps like a purchase, and on sensitive sites **Watch mode** pauses it if you switch away from the tab. [OpenAI's guidance](https://openai.com/index/prompt-injections/)
- **Claude Code:** use **Manual** mode in repositories you don't know. In Manual, network commands like `curl` and `wget` ask first, and MCP servers listed in a project's `.mcp.json` need your approval. Run untrusted code in a sandbox, dev container or virtual machine. See [the six permission modes](/guides/claude-code-permission-modes).
- **Everywhere:** ask for specific tasks. "Summarize my unread emails" gives hidden instructions less room than "go through my inbox and handle whatever needs doing."

## Before you connect anything

- [ ] Does this agent have private data, untrusted content **and** a way to send data out? Take one away.
- [ ] Set sending, editing and deleting to **Needs approval**.
- [ ] Read each confirmation, including exactly what's being shared.
- [ ] Give specific tasks, not open-ended ones.
- [ ] Install MCP servers only from sources you trust, and recheck them after updates.
- [ ] Scan pasted prompts, templates and rules files for hidden characters.
- [ ] Open unfamiliar repositories and scripts in a sandbox or virtual machine.

**Go deeper:** [OWASP LLM01:2025](https://genai.owasp.org/llmrisk/llm01-prompt-injection/), [Claude Code security](https://code.claude.com/docs/en/security), [MCP vs CLI](/guides/mcp-vs-cli), [Claude Connectors](/guides/claude-connectors).
