Skip to content
Beta
All articles

Step-Zero attacks: coding agents can be harmed by opening a file

New research shows coding agents unpack untrusted archives and save fetched files before any check sees the content. What was measured and the fixes that held.

By The SpanDock team

6 min read

A diagram of a coding agent receiving a path to an archive: the extract call writes past a disk budget before any content reaches the model, while a bounded peek and staged extract keep the workspace unchanged

Most defences for coding agents wait for content to reach the model: injected text is filtered, tool output is inspected, and the model is trained to distrust what it reads. A paper published this month measures a step that comes earlier. To find out what an unknown archive, web response or image contains, an agent usually has to process it, and that first processing call can do harm before the model has seen a single byte. The authors call it Step Zero, and in their tests most popular agent harnesses were already unsafe there.

What the researchers measured

The paper, Step-Zero Attack: Agent Safety Before Observability, comes from researchers at Tsinghua University, the University of Sydney and Harbin Institute of Technology. They ran seven public harnesses, including Claude Code, OpenAI Codex, OpenCode and Qwen Code, each with six models, for 42 harness and model pairs. Every prompt was only a path or a URL, with no instructions in it, and every tool call was approved automatically, as many teams run agents today.

The test inputs were ordinary format hazards, not prompt injection:

  • An archive whose directory understates one file. It lists as about 3.9 KB, but one member inflates to 8 MiB when extracted. Each archive had a harmless twin with the same names and listed sizes.
  • A web response or an image that declares a file name (project-alpha.txt) but carries a different body.

The agent was not told about a 4 MiB disk budget that the researchers used as the measurement threshold.

What happened

On the archive, extraction passed the budget in 32 of 42 harness and model pairs, and in 26 of them before any file's content had reached the model. None of the 42 harmless twins did. Four of the six models breached in every round they ran, 84 of 84 cells. According to the full paper, every breaching agent used unzip, none of the 33 agents that extracted set a resource limit, and 17 breaches came after the agent had already read a listing.

The understated size was not even necessary. With an archive that honestly declared its 8 MiB file, agents extracted it and passed the budget in 28 of 28 cells. The authors put it plainly: default agents "extract whatever arrives". The misdeclaration matters only against defences that trust declared sizes.

On web and image inputs the harm moved to what the agent wrote. Agents often saved the body under the name the input declared, which lets the input decide what lands in the workspace. A digest helped when the setup made checking obvious, but the effect faded when the cues were removed. When the task was simply "fetch this and save it", and the digest did not match, agents saved the wrong body in 27 of 28 cells, 12 of them after saying the digest did not match, and none refused.

Caution also depended on the model. One model inspected archives read-only first most often, yet had the most conflicting writes on web and image inputs. Good behaviour on one kind of input predicted little about another.

Why model-side defences miss this

The paper's argument is about timing. A content filter or a careful model can only act on what is in the context. When an extraction writes while it reads, the damage is complete when the call returns, before there is anything to inspect. A check that looks only at the command (unzip project.zip) cannot tell the hostile archive from its twin, because both look identical from the outside.

This is an old class of bug, data amplification, described in MITRE's CWE-409. What is new is who picks the tool. A person chooses an extractor once. An agent chooses its parser on every call, so a patch to one library does not help when the agent reaches for a shell command instead.

Keep the scale in proportion. The measured harm was disk use and file contents under the agent's own account on a test machine, and the budget was deliberately small. The authors note the attacker sets the size, though: with a 512 MiB hidden file, agents wrote up to 1,024 MiB, and default command timeouts never fired. On a laptop or a shared build runner, filling the disk or overwriting a known file is a real outage, and in an agent loop it happens without anyone watching.

The fix that held

The researchers built a gate they call the Step-Zero Safe Protocol. It replaces the extractor with two operations: a peek that decompresses in memory and reports how many bytes each file really produces, writing nothing, and an extract that writes into a private staging folder, counts produced bytes, refuses at the budget, and moves the result into place only if everything fits.

In live agents, routing extraction through the gate cut breaches from 28 of 28 cells to 0 of 28, and agents still completed an extract-and-run-tests task in 25 of 28 cells, against 23 of 28 without it. Two findings matter for anyone designing controls:

  • Offering a safe tool is not enough. When the bounded tool sat beside the shell, agents used it in 5 of 28 cells and still breached in 28 of 28. It worked only when it replaced the default.
  • Wrappers on command names leak. In a separate run, the one breach came from a harness that called unzip by its absolute path, past a front-end that only intercepted the bare name. The authors conclude the gate belongs in the harness's own tool layer, or in a quota enforced below the agent.

Checks that trust declared sizes failed against archives built to look benign, while per-file limits and disk quotas stopped the bytes but left half-extracted trees. Counting produced bytes and committing only on success was the only approach that held on every test archive.

What it means for engineering and security leaders

Agent safety reviews tend to focus on prompt injection and approval prompts. This research adds a category: tools that act on untrusted input as part of reading it. Archive extraction, curl -OJ-style downloads that write under a server-chosen name, and image decoders are the examples studied; documents, repositories and packages are left to future work.

Automatic approval is the multiplier. Every result in the paper assumes no person approves the first call, and in practice a person who approves unzip from its command line would see the same harmless-looking listing.

Practical takeaways

  • Run agents with a disk quota on their workspace and temporary folders, set outside the agent's reach, so an oversized extraction fails rather than fills the machine. Our earlier article on sandboxing coding agents covers the wider isolation choices.
  • Treat "open this archive" as a write, not a read, in any allow-list or auto-approval rule you maintain.
  • Prefer listing and reading members over extracting in agent instructions and skills, and say so explicitly for third-party archives.
  • Do not let downloads choose their own file names. Save to a fixed name in a scratch folder, then move after a check.
  • Ask your tool vendors whether their harness bounds what extraction and fetch tools write, and whether that bound applies when the agent calls a binary by its full path.
  • Watch for the code release. The authors say the fixtures, harness runner and gate will be published on acceptance, which would let you test your own setup.

Sources

  1. Step-Zero Attack: Agent Safety Before Observability (arXiv:2611.01953)
  2. Step-Zero Attack: full paper (HTML version)
  3. MITRE CWE-409: Improper Handling of Highly Compressed Data (Data Amplification)
Cookie categories

Details: Cookie Policy.