Your coding agent shouldn't be holding your API keys
Everything that runs in an agent's VM can read the keys you gave it, and 2025's npm attacks went looking for exactly those. Why the usual fixes fall short, and what we do instead.
5 min read
Here is how almost everyone runs a coding agent today, us included until recently. You start a sandbox, put GITHUB_TOKEN, STRIPE_KEY and ANTHROPIC_API_KEY in its environment, and let the agent work for a few hours. It needs those keys to open pull requests, run tests against Stripe's test mode and talk to the model.
The agent is not the only thing that can read them. Everything that runs in that VM can: every npm install, every install script, every test, every binary the agent decides to download. And the agent itself reads untrusted text all day, from issues, READMEs, web pages and error messages, any of which can ask it to do something you never asked for.
None of this is new. That is the point.
This already happened, twice, in 2025
- s1ngularity (Nx, August 2025). Attackers got hold of an npm publishing token through a GitHub Actions injection flaw and published malicious versions of the Nx build system. The Nx postmortem and advisory GHSA-cxm3-wv7p-598c describe code that scanned the machine for credentials on install and uploaded what it found to a public repository under the victim's own GitHub account. It also tried to use AI tools already installed on the machine to do the searching. Wiz's analysis shows it launching the Claude, Gemini and Amazon Q command-line tools with their permission prompts switched off. That AI step got data out in under a quarter of cases, often because the tool was misconfigured or the model refused. The attackers were betting that the tool with the widest access on a developer's machine is now the agent.
- Shai-Hulud (npm, September 2025). A self-spreading worm that ran during package install, collected environment variables, npm and GitHub tokens and cloud keys, and used any npm token it found to publish infected versions of every package that token could reach.
Neither attack needed to fool the agent. They needed one install and a key in reach. An agent installs packages all day, often ones nobody has read.
Then there is prompt injection. Models have become much better at spotting instructions hidden in a README or an issue, but "the model usually refuses" is not a security boundary. You would not accept that sentence about a firewall.
And agents now run unattended. The whole value of an overnight agent is that nobody approves each command, which also means nobody is watching when a dependency does something odd at 3 a.m.
So the question is not whether something in the VM will try to read your keys. It is what it gets when it does.
The usual fixes don't hold
| Fix | What it helps with | What it leaves open |
|---|---|---|
| Filter the prompts | Some injected instructions | Install scripts never pass through the model |
| Scoped tokens | How much damage a stolen key does | The theft; a scoped token still works for whoever holds it |
| Lock down outbound traffic | Unknown destinations | Breaks npm, pip and apt, so it gets switched off within a day |
| Approve every command | Everything | Then it is not an overnight agent anymore |
Scoped and short-lived tokens are still worth using. They limit the damage. But each of them assumes the key sits inside the machine and only asks how bad it gets when it walks out.
What we do instead: the key never enters the VM
In Zode the sandbox never holds the real value. Each secret has a placeholder, and that placeholder is what the agent's environment contains:
$ env | grep -E 'STRIPE|GITHUB'
STRIPE_KEY=zode_vault_7f92a1...
GITHUB_TOKEN=zode_vault_c03e9b...The real value stays in memory on the host, in an egress proxy outside the VM. You list the hosts each secret may go to. When the agent calls one of those hosts over TLS, say api.stripe.com for STRIPE_KEY, the proxy swaps the placeholder for the real key on the way out, and the call just works.
Everywhere else, nothing of value leaves:
- A script that reads the environment and posts it to its own server over HTTPS sends placeholders. They mean nothing outside that one sandbox.
- A placeholder sent over plain HTTP, sent in base64, hex or URL-encoded form, or sent to a host the proxy is watching but that secret is not allowed for, is refused with a 403 before it leaves the host.
The setup is a few lines; the earlier post on secrets walks through it.
The trade-offs, because you will ask
- The proxy reads some TLS traffic. To put a key into an HTTPS request it has to see that request. Each workspace has its own certificate authority, trusted by its sandboxes, and the proxy opens only connections to hosts a secret allows and to known AI provider APIs. Every other connection passes through unread. If you need end-to-end TLS to a host, don't attach a secret to it.
- Code in the VM can still use a key while the VM runs. It cannot take the key away, but it can make its own request to an allowed host and the proxy will swap the key in. Keep each secret's host list narrow. Every swap is recorded per sandbox, spend caps can pause a machine, and once it stops there is nothing left to steal.
- Not every credential can work this way. Credentials that sign requests, such as AWS secret keys and PEM keys, and database connection strings never appear as a plain value in a request, so we refuse to store them as swappable secrets. Use short-lived credentials for those.
- It is new. We launched this week. Hosts are Google Cloud VMs with nested KVM in Belgium; bare metal and a US region come next, and host attestation is not shipped yet.
Why this matters more every month
A year ago one person ran one agent and watched it. Now people run ten at once and read the pull requests over breakfast. If the work is unattended, the boundary has to hold with nobody watching. "The model probably won't do that" can't be that boundary. Not putting anything worth stealing inside the VM can.
Zode is what we built around that idea: full Linux VMs for coding agents, with Docker, Chrome and a desktop, about $0.045 an hour for 4 vCPU and 8 GB, with keys kept on the host. But the idea matters more than the product, and we would be glad to see every sandbox do this. If you find a way to get a real key out of a Zode VM, we want to hear about it.
Try it: install the CLI, or start free in the console.
curl -fsSL https://zode.dev/install | sh