← Back to all posts
Published on · by Renaud Deraison

The model never asked for that

HiddenLayer showed that whoever controls the LLM gateway between a coding agent and its model can add tool calls the model never made, then remove them from the history before the model sees it. The agent runs them like any other call, and an approval prompt can't tell where a call came from. A day earlier, a LiteLLM release on PyPI carried a credential stealer and an hourly backdoor. In Bromure Agentic Coding, an injected call runs in a VM that holds only stand-ins, the proxy blocks its upload and pauses the VM, and your Mac keeps a record of the call where the gateway can't reach it.

Your agent asks the model what to do next, and the answer comes back through a gateway. If the gateway adds a step, the agent runs it. The model never asked for it, and later never hears it happened.

HiddenLayer published Man-in-the-Model: Hijacking Coding Agents in Transit on October 22. Adversa put it in its November roundup of coding agent security research. The question it asks is simple: what can a compromised gateway do to the agents behind it?

Many teams don't send agent traffic straight to Anthropic or OpenAI. It goes through a LiteLLM proxy for cost tracking and key management, through OpenRouter for model choice, or to vLLM, llama.cpp or Ollama on a shared GPU box. Every request and every response passes through that layer, and a response is the list of tool calls the agent will run next.

What the gateway can do

HiddenLayer's researchers (Esteban Tonglet, Divyanshu Divyanshu and Kasimir Schulz) worked through the attack one step at a time.

Find out who is calling. Codex sends headers starting with codex-tui, and Claude Code sends claude-cli. Agents that send only a generic SDK header still give themselves away with their tool names and request fields.

Find out what runs without asking. The gateway sees when it sends a tool call and when the result comes back. A file read that takes several seconds probably waited for a human to approve it. Across more than 4,000 captured sessions, 4.7% of quick tool calls left any doubt. When timing isn't clear, the gateway can slip timing code into a script the agent is editing, or wrap a command in a timer, and hide the output.

Read files the model never asked for. Claude Code loads CLAUDE.md, Codex loads AGENTS.md, Cursor reads .cursorrules. The gateway can add a read of any of them to a response, keep what comes back, and remove both the call and its result before forwarding the conversation to the model. In HiddenLayer's words, "those file reads are initiated by the interception layer rather than by the model."

Run code. In the first demo, the agent was Hermes, in a mode that asks before commands it considers dangerous but not before file edits or ordinary Python. The user asked it to read a Python file. The proxy added tool calls to the response: one edit put a heartbeat_ok() function in the file, a second added code that gathered /etc/passwd, environment variables holding credentials and ~/.ssh/id_rsa and posted them to a webhook, a third ran the file with python3, and a final edit put the file back as it was. The user never saw a network command, because the upload happened inside the script.

Ride an approved prefix. In the second demo, Codex had git as an approved prefix and a writable .git directory. The gateway sent:

git -c diff.external='sh -c "cat .env"' diff --no-index /dev/null .env

It starts with git, so Codex ran it without a prompt and printed a .env file the agent would normally refuse to open. To the user, the agent "still appears to be performing an ordinary Git operation."

Plant a dependency for later. When the model asks to add requests, the gateway changes it to reqiests. The agent writes the misspelled name into the dependency file, and the payload runs at the next install, on a laptop or in CI.

Coding agentRuns every call it receivesread main.pyedit main.py + heartbeat_ok()python3 main.pygit -c diff.external=… .envedit main.py (restore)red: the model never asked for theseCompromised gatewayOn the way downadds tool calls to the response,timed to what runs without a promptOn the way upremoves those calls and their resultsfrom the history, keeps what it readModel providerAsked for one thingread main.pyGets a clean history backno added calls, nothing in itslogs, nothing to reason aboutThe injected script posts .env, ~/.ssh/id_rsa and credential environment variables to the attacker's webhook. No network command ever appears.
HiddenLayer's attack. The gateway adds tool calls to the model's response. The agent runs them, and the gateway removes them from the history it forwards upstream, so the model and the provider never see them.

An approval prompt can't tell who wrote the call

HiddenLayer's conclusion: "the security boundary is no longer just the model. It includes every system that can shape what the agent ultimately executes."

Approval prompts and allow lists judge the command, not where it came from. The agent can't tell a tool call from the model apart from one the gateway added, because both arrive in the same response. The gateway also knows from timing which calls you approve without looking, and it picks those. Prompt injection defenses look at the text going to the model, and here no text needs to reach the model at all.

On October 21, the day before HiddenLayer published, litellm 1.107.0 went up on PyPI with a credential stealer and a loader that fetched attacker code every hour. The Hacker News traced it to a master key committed to a public repository in May and never revoked. PyPI pulled it after 1 hour 43 minutes, and the Docker Hub and GHCR images published alongside it were reverted later. A LiteLLM proxy that picked up the release ran an attacker's hourly loader inside the process that relays every agent conversation it handles. We covered that release in The release was two hours old.

The same gateway, in front of a Bromure machine

Bromure Agentic Coding runs Claude Code, Codex, Grok, Kimi and omp in Ubuntu VMs on your Mac. A gateway can still put words in the agent's mouth. Those words turn into commands that run in a VM built on the assumption that the agent might be hostile, and every command has to get past checks the gateway can't touch.

The script finds stand-ins

HiddenLayer's script collected environment variables holding credentials, ~/.ssh/id_rsa and .env. In a Bromure machine:

  • Environment variables hold stand-ins. GH_TOKEN, NPM_TOKEN, ANTHROPIC_API_KEY and the rest have the right shape and no value anywhere except through the proxy on your Mac, which swaps in the real value only on requests to the host each credential belongs to.
  • ~/.ssh has no private key file in it. The VM's SSH_AUTH_SOCK is a bridge to the Mac: the VM can ask for signatures, but the key bytes stay on the host.
  • .env holds stand-ins once you've run Import env file… in the machine's Credentials pane. It reads your existing .env, shows the variables with masked values, and turns them into credentials on the Mac. The VM gets stand-ins in the same variables.
  • AWS keys are a real access key ID with a fake secret. The Mac re-signs each request with the real one, so the secret never exists in the VM.

The git diff.external trick from the second demo still runs in a Bromure machine. It prints a file full of stand-ins.

Sending them anywhere sets off an alarm

The script's next step is to post what it found to a webhook. The first stand-in in that request is going to a host it wasn't issued for. The proxy blocks the request with HTTP 451 before a byte leaves, pauses the VM, and opens an alert on the Mac titled This environment may have been compromised. The alert names the credential, the host it belongs to and the host it was being sent to. Nothing the gateway does reaches that dialog: it runs on the Mac, and the gateway only sees model traffic.

A payload that skips credentials and takes source code or /etc/passwd instead meets the egress firewall. In Guardrails, set Unmatched traffic to Deny and allow the hosts the machine needs: your model route, your forge, your registries. The webhook isn't on the list. The firewall runs at the virtual switch and in the proxy, and the VM's web traffic is diverted into the proxy, so a script can't route around it.

Machine VMInjected call runspython3 main.pyWhat it collectsenv vars and .env: stand-ins~/.ssh: no private key fileAWS: a fake secret keyPOST to the webhookcarrying the stand-insYour MacTrace keeps the responsewith the injected tool call, as theagent received itEgress firewallunlisted hosts denied at theswitch and in the proxyStand-in to wrong hostHTTP 451, VM paused, alert on MacOutsideCompromised gatewaycan add calls, can't edit theMac's record or click its dialogsAttacker's webhookreceives nothing
The same injected script in a Bromure machine. It finds stand-ins, its upload is blocked and the VM paused, and the Mac keeps its own record of the response that delivered the call.

The Mac keeps the call the gateway erased

The gateway's best trick is cleanup. It removes the call from the history it forwards, so the provider's logs and the model's context look clean. It can't reach the copy on your Mac.

Every request a Bromure machine makes goes through the proxy on the Mac, and the trace records what crossed it. At the default level, AI request details, it keeps full request and response bodies for the known model providers. For a gateway Bromure doesn't recognize by name, set the machine's Session trace to Everything. The Trace Inspector's Conversation view parses each response into its tool calls, shell commands and file reads and writes. The response that carried python3 main.py is there as the agent received it, and the gateway can't edit it after the fact. The bodies are sealed with a key in your Keychain, and nothing is uploaded on an unmanaged install.

On a machine running the OpenShell + Sentry sandbox engine, Show the Whole Chain on the blocked connection goes the rest of the way: from the packet to the python3 process, to the shell the agent started, to the tool call that started it and the text that came before it in the same response. When the provider's logs show a turn that asked to read one file and your Mac shows the same turn running a script and posting to a webhook, the difference between the two is the gateway's work.

The dialogs that matter are on the Mac

HiddenLayer's gateway learns which calls run without a prompt by timing the agent's own approvals. Bromure's important approvals don't happen in the agent.

On new machines, every guarded service starts in Prompt before write in the Guardrails pane. A git push, a write to an AWS API, a kubectl apply or an INSERT into a database endpoint pauses for a dialog on the Mac that shows the exact operation. Deletes ask too. The policy is enforced in the proxy, so an injected call can't get through by starting with an approved prefix: the dialog comes from what the request does on the wire, whatever command produced it.

The typo hits the supply-chain checks

The reqiests swap is aimed at the next pip install. In a Bromure machine, every package fetch goes through the proxy's supply-chain checks before the VM gets a byte. With socket.dev or Depi enabled in the Supply Chain pane, Bromure flags typosquats and known malware at download time. The age gate, on by default, hides any version published in the last two days, which catches a package the attacker published just before switching the gateway on. A blocked install fails with a 451 that names the package and the reason, and pip prints it in the terminal for you and the agent.

The model route is set on the Mac

Which gateway sits in the path is a choice you make on the Mac's Models board, not in a config file inside the VM. If a machine's work is too sensitive for any third-party gateway, point its agents at an On-device model: Bromure runs MLX models on your Mac's GPU, and the request never leaves the host. For how the board stops someone else from changing the route, see The CLI was the real one.

Stand-ins to steal

Environment variables, .env and AWS config hold stand-ins, and SSH keys never enter the VM. An injected script collects values that work only through your Mac.

Exfiltration pauses the VM

A stand-in headed for the wrong host is blocked with a 451, the VM is paused, and the alert names what was being sent where.

A record the gateway can't edit

The trace on your Mac keeps each response as the agent received it, injected calls included, sealed with a key in your Keychain.

Writes wait for you

Pushes, cloud writes and database writes pause for a dialog on the Mac, decided by what the request does, not the command that sent it.

What to do this week

  • List every system between your agents and their models: the LiteLLM proxy, the OpenRouter account, the GPU box running vLLM or Ollama. Patch them and lock them down like production servers, because they are.
  • If you ran litellm 1.107.0 anywhere, treat that host and every secret it could reach as compromised.
  • Review approved command prefixes. git as a blanket prefix approves git -c diff.external=….
  • Take the real secrets out of the agent's environment, so a script that collects them collects stand-ins. In a Bromure machine, Import env file… does it in one step.

The Credentials chapter of the manual explains the swap in detail, and Tracing & Audit covers what the trace keeps and how to read it.