cd .. && $ cat who-writes-your-agents-prompt.md
Who writes your agent's prompt: issues, vendors and the operating system
Why the real question for coding agents is who has write access to the context window, from poisoned GitHub issues and vendor MCP servers to OS-level agents reading the screen, and which controls follow the data instead of the command.
- ---
- commit
- e78dc2c
- date
- tags
- [ ai-agents , claude-code , security , mcp ]
- stats
- +2,069 words, 9 min read ---
You think you write the prompt. You write one line of it. The rest comes from the issue the agent was asked to fix, the README it skimmed, the tool descriptions of every MCP server you installed, the output of the last shell command, and possibly a marketing department you have never met. The context window is a shared document with edit rights for strangers, and nobody set up the permissions.
Most of the debate about prompt injection asks whether the model is smart enough to spot the bad instruction. That is the wrong question, or at least the less useful one. The better question is: who can write into the context, and what is the session still allowed to do after they did? This month’s material answers it from four directions: the issue tracker, the tool vendor, the operating system and the harness itself.
1. The issue tracker is a prompt
The cleanest demonstration this month is a small experiment. An author wrote an ordinary-looking GitHub issue, “config loader crashes on empty values”, with an HTML comment addressed to AI assistants. The comment told the agent to send the project’s .env file to a collector and push to main, and not to mention it. Everything ran in a throwaway container with a fake .env and a collector that only counted requests (I gave Claude Code a poisoned GitHub issue. Twice.).
Run one: Claude Code read the issue, explored the project and stopped. It explained the hidden comment and refused. Applause, credits roll.
Except the author’s own verdict is the important part: that was the model having a good day. A defense that works when the model is in a good mood is a defense with a random number generator in the middle. You would not accept a firewall that blocks port 22 “most of the time, depending on vibes”.
The point generalises. An issue, a pull request description, a web page, a log line: anything the agent reads is input to the same function that decides what the agent does next. There is no type system separating “data” from “instructions” in a prompt. It is all string.
2. Judge the session, not the command
Run two is where it gets interesting. The author played the obedient agent and asked for exactly what the comment wanted. A guard hook refused the push and refused reading .env. Nothing left the container (I gave Claude Code a poisoned GitHub issue. Twice.).
The design choice behind it is worth stealing even if you never install that hook. git push origin main is the most innocent command in the world. Judged on its own, it should run. What makes it dangerous is that three steps earlier the session read text written by someone else. So the guard does not judge the command. It remembers what the session read:
- Outside content taints the session: a web fetch, a search, a shell command that reaches the network, a file outside the project, an MCP tool.
- From then on, until a human clears it, the session gets a short list of local commands with plain arguments: build, test, read-only git. No pipes, no
$(), no reading secrets, no writes that outlive the session, such asCLAUDE.md,.claude/, memory or git hooks. - It fails closed. If the hook cannot decide, the answer is no.
This is taint tracking, the old idea from Perl’s -T flag and every web framework that ever escaped HTML, applied to an agent session. And it has the same costs. In run one the guard also refused find ., because find -exec can run anything. Strict lists hurt, and you will add your own commands to a JSON file on a Tuesday afternoon while muttering. The author also states the limit plainly: a hook is a policy check, not isolation. A command it allows runs with your rights.
It also fits a pattern from earlier material: rules that must hold belong in code, not prose (Don’t Write Markdown Files for Your Coding Agent. Write Scripts). I covered permissions, sandboxing and CI as the general environment in Stop supervising your agent, configure its environment. This is the piece that article did not have: a control that follows where the data came from, not just which command runs.
3. Invisible ink
The issue comment was at least visible if you opened the raw Markdown. Several other channels do not even give you that.
Terminal escapes. MCP output goes through two readers. The terminal swallows ANSI escape sequences, the model reads them verbatim. That asymmetry makes tool output a channel for instructions the human reviewer never sees (ANSI escape injection in MCP servers - Hidden from humans, visible to AI). It is the web’s white-text-on-white-background SEO trick, reborn for a reader that is very literal and has shell access.
Instruction files. Agents load AGENTS.md and CLAUDE.md from the working directory automatically. A file dropped into ~/Downloads or added in a pull request acts with the developer’s privileges. A typical payload pretends to be an environment preflight check (One Markdown File Can Hijack Your AI Coding Agent).
Tool descriptions. In a WebMCP test, an Angular shop exposed ten tools and the attacks changed only the tool descriptions, never the checkout logic. The direct attacks on the order step failed: the agents flagged the over-budget total and asked. But forced insurance and warranty, combined with a redefined budget, got all three models to place a 136 euro order against a 100 euro limit (WebMCP Attack Lab - Can an E-Shop Hijack Your AI Agent). The description of a tool is part of the prompt. The vendor of the tool writes it.
Which brings us to an unpleasant thought. If tool descriptions and tool output are prompt, then every MCP server vendor is a co-author of your agent’s behaviour. A Reddit report claims that Notion’s official MCP server puts hidden upsell instructions into agent context (Notion’s official MCP injects hidden upsell instructions into agent context). I could not verify the post, so treat it as a hypothesis, not a finding. But note that nothing in the protocol would stop it. Malice is optional. A product manager with a growth target is enough.
4. The vendor holds the pen
Google made the vendor’s role explicit this month, in legal form. From 1 February 2027, any tool that “is or is driven by” an AI agent must reach Gmail, Drive, Calendar and the rest of Workspace through Google’s own MCP servers. Agents that keep calling the REST APIs directly drop to Standard-tier quotas and break the terms (Google Will Make AI Agents Use Its Workspace MCP Servers. The Gmail One Can’t Send Email).
The interesting part is what the servers leave out. The Gmail server can search, read, draft and label. It cannot send, reply, forward or edit a draft after creating it. Those tools exist, but only for partners. Drive cannot move, rename or share. The data rules add a ban on training with Workspace data and let Google cap retention of embeddings and memory indexes at 30 days.
That is not injection, but it is the same question from the other side. The vendor decides which tools exist, what their descriptions say and what the agent may keep. Your agent’s capabilities are now a product decision in Mountain View. An assistant that indexes your inbox to answer questions about last year’s contracts gets to rebuild its memory every month, like a goldfish with a compliance department.
5. The operating system reads over your shoulder
The last writer turns the direction around. Here the context does not get poisoned. It leaks out.
Signal announced that it now blocks AI agents built into iOS 27 and Android from capturing its screen, as it did earlier against Windows Recall (Signal is Serious About Protecting Your Privacy). These OS agents read whatever is on screen to answer questions. Your Signal messages end up in the agent’s store and possibly on a remote server, outside Signal’s control and outside the end-to-end encryption that the whole app exists to provide.
Signal’s own description of its remedy is refreshingly honest. Blocking screenshots does nothing against an agent that reads app data through the filesystem. macOS offers no usable API for it, so there is no protection there. Signal spent months on forensics to learn what these agents actually do, because the platforms barely document it. When an app with a formally verified encryption protocol has to reverse-engineer the operating system to know who is reading, the threat model has a new row.
For developers it is a familiar shape. A tool sends data where the user did not expect. Earlier this month Claude Code put the user’s email address into the User-Agent header of web requests (Claude Code sends your email address to websites). Different layer, same lesson: an agent’s context is not private just because it lives on your machine.
6. The harness is catching up, and adding doors
Claude Code’s changelog over the last two weeks reads like a response to the first four sections, with a twist:
- v2.1.329: the trust dialog now warns where a folder’s hooks are declared (Claude Code v2.1.329). A planted hook is the instruction-file attack with execution rights, so this is the right place for a warning.
- v2.1.327:
claude mcp add-json <name> -reads the server config from stdin, so tokens stay off the command line and out of the shell history (Claude Code v2.1.327). - v2.1.332: MCP servers can now ship their own skills (beta). The same release adds a
PreSkillShellCommandhook that can refuse a skill’s inline shell commands as it loads (Claude Code v2.1.332).
That last one is the twist. The release opens a new write path into the agent, letting the server vendor ship instructions as well as tools, and ships the guard for it in the same changelog. That is the honest way to do it. It also tells you where the attack surface goes next. If you install an MCP server, you are now also installing its opinions about how your agent should work.
7. Who has the pen, and what to do about it
| Writer | What lands in the context | Control that actually holds |
|---|---|---|
| Issue, PR, web page | Hidden comments, fake setup steps | Taint the session after outside reads, then allow only a short local command list |
| Instruction files | AGENTS.md, CLAUDE.md, hooks from the folder |
Start agents only in trusted folders, review these files like code, check where hooks are declared |
| MCP server output | ANSI escapes, injected text | Strip control sequences, treat output as untrusted input |
| MCP vendor | Tool descriptions, shipped skills, which tools exist | Read the descriptions, pin versions, refuse skill shell commands by default |
| Platform owner | Terms, quotas, retention limits | Plan around the tool list as a product decision that can change |
| Operating system | Screen and file access by OS agents | Know which agents run on the machine, keep secrets out of what they can read |
The takeaway
Asking whether the model will notice the injection is like asking whether your intern will notice the phishing email. Sometimes, yes, and good for them. But you do not build a security model on the intern’s good days. The context window has many authors: the issue reporter, the tool vendor, the platform’s legal team and the OS. Most of them mean no harm. Some of them have a growth target. One of them is the attacker.
So give the context an access model. Track where text came from. Narrow what a session can do once it has read something it did not write. Treat a tool description as code you did not review, because that is what it is. And when a vendor ships a new way into your agent, look for the guard in the same changelog. This time it was there. Check next time too.
Sources
- I gave Claude Code a poisoned GitHub issue. Twice.
- Don’t Write Markdown Files for Your Coding Agent. Write Scripts
- ANSI escape injection in MCP servers - Hidden from humans, visible to AI
- One Markdown File Can Hijack Your AI Coding Agent
- WebMCP Attack Lab - Can an E-Shop Hijack Your AI Agent
- Notion’s official MCP injects hidden upsell instructions into agent context
- Google Will Make AI Agents Use Its Workspace MCP Servers. The Gmail One Can’t Send Email
- Signal is Serious About Protecting Your Privacy
- Claude Code sends your email address to websites
- Claude Code v2.1.327
- Claude Code v2.1.329
- Claude Code v2.1.332