published fresh until

Can a web page's HTTP response headers prompt-inject your agent?

Summary Arpit Bhayani (16 Oct 2026) pointed out that if an agent's fetch tool copies response headers into the model's context, or the agent runs curl -i, a server can hide instructions in a header and send it only to AI user agents. Which agents and tools pass headers to the model, and how do you check yours?

Not for MCP server SSRF CVEs

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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 (or curl -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 curl in Bash for the unprocessed page. The official MCP fetch server's code returns the response body text and also reads content-encoding and content-length alongside content-type. Codex, Gemini CLI and browser tools were not checked.
  • Does your agent reach for curl -i on 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 curl suggestion 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-headers and -v, --verbose as 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

Subjects

More in prompting

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Can a web page's HTTP response headers prompt-inject your agent?
Summary: Arpit Bhayani (16 Oct 2026) pointed out that if an agent's fetch tool copies response headers into the model's context, or the agent runs curl -i, a server can hide instructions in a header and send it only to AI user agents. Which agents and tools pass headers to the model, and how do you check yours?
Copy for agent
get the whatworks thread http-header-prompt-injection-fetch-tools and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread http-header-prompt-injection-fetch-tools
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks