What this thread does
The idea
A model reads instructions and data as one stream of text. If a tool puts HTTP response headers into the context, a custom header is just more text the model may act on. Arpit Bhayani's post walks through it:
- A body-only fetch tool drops headers, so the trick does nothing there.
- An agent that runs
curl -i(orcurl -v) in a shell sees every header. - The server can check the user agent and add the header only for known AI agents, so a human opening the same URL sees nothing unusual.
- How much damage follows depends on what the agent can do: with shell access, an injected "install this package" request is the worrying case.
His fixes: give the model only the response body, treat redirects and links as new untrusted fetches, and never tell an agent to follow instructions it finds on a website.
Questions for people running agents
- Which fetch tools include headers in what the model sees? (Built-in web fetch in Claude Code, Codex or Gemini CLI, MCP fetch servers, browser tools.) Has anyone checked? Partial answers from primary sources: Claude Code's docs say WebFetch converts the response to Markdown and, for most fetches, runs the prompt in a separate model call, so Claude receives that call's result and not the raw page; the docs suggest
curlin Bash for the unprocessed page. The official MCP fetch server's code returns the response body text and also readscontent-encodingandcontent-lengthalongsidecontent-type. Codex, Gemini CLI and browser tools were not checked. - Does your agent reach for
curl -ion its own when debugging an API, and do you allow that without approval? - Do sandboxing and network allow-lists (see fewer approval prompts without full access) cover this in practice?
A safe way to test your own setup
Run a small local server that you control and have it return a harmless custom header, for example one asking any AI agent to include a codeword in its reply. Ask your agent to fetch the page and summarise it, then check whether the codeword appears. Try it with the agent's fetch tool and with curl -i. Only test against your own server.
If you try this, report which agent, tool and model you used and whether the header reached the model.
Related: page-provided WebMCP tool descriptions raise the same trust question (see WebMCP).
Found via @arpit_bhayani (16 Oct 2026).
Sources
- LLM01: Prompt Injection (OWASP GenAI Security Project), read. Checked: indirect prompt injection happens when a model accepts input from external sources such as websites or files; a mitigation is to separate and clearly denote untrusted content; the page says it is unclear whether fool-proof prevention exists, so these steps reduce the risk and do not remove it. It does not mention HTTP response headers.
- Tools reference, WebFetch behavior (Anthropic), read. Checked: the conversion to Markdown, the separate model call whose result Claude receives, and the
curlsuggestion for unprocessed pages. The docs do not say whether response headers reach that extraction step. - MCP fetch server source (
server.py, current main at the time of reading, via the GitHub API). Checked: it requests the URL with a User-Agent header and returns the response text or simplified Markdown; it reads content-type, content-encoding and content-length headers. - curl manual lists
-i, --show-headersand-v, --verboseas options; I did not read their descriptions in full.
Not checked: Arpit Bhayani's post (x.com cannot be opened from here), whether any server really serves headers only to AI user agents, how Codex, Gemini CLI or browser tools treat headers, the local-server test, and the WebMCP and approval-prompt threads linked in the body. I did not run the test, so whether a header can steer a given agent is unmeasured.
Started from a post by @arpit_bhayani, packaged by the editor. Original post