Skip to content
Beta
All articles

ParseGap: when a coding agent approves one command and the shell runs another

A study of eight coding agents found approved shell commands that wrote files or ran programs. Why read-only allow lists fail, and what to change in your setup.

By The SpanDock team

5 min read

A diagram of one command string read twice: the agent's approval gate parses it and sees a read-only uniq call, while the shell runs it and uniq writes its second operand to a file outside the workspace

Most coding agents decide whether to run a shell command by parsing the command text, checking it against an allow list, and then handing the same text to a real shell. A paper published on 22 November 2026, ParseGap, tested what happens in the gap between those two readings across eight production coding agents. Every agent's checker approved commands made only of "read-only" utilities that, once the shell ran them, wrote files or started programs. If your team relies on an allow list of safe commands to let agents work without prompts, this is worth an hour of your time.

What the paper tested

The author, from Fudan University, built a differential testing framework. Each input goes through the agent's own unmodified command checker, and separately through GNU Bash 5.2 in an isolated container, where the framework records which processes start and which files change. A violation is any command the checker allowed whose real effects break the policy.

The eight agents were Roo Code, Cline, Continue, OpenCode, Gemini CLI 0.70.0, Qwen Code 0.28.3, Mistral Vibe 3.1.4 and OpenAI Codex CLI 0.171.0, pinned in November 2026. Claude Code, Cursor and GitHub Copilot are not among them, although the paper's count of public advisories includes them: it lists 171 shell-approval-bypass advisories between July 2025 and October 2026, 58 of them across ten mainstream coding agents.

The paper groups the failures into 17 root causes at three boundaries.

The parse

The checker and the shell can split a command differently. The paper reports a defect in the upstream tree-sitter-bash parser, used by Mistral Vibe and Gemini CLI, in which a particular two-line input makes the parser fold the second line into an argument of the first command. Bash runs the second line as its own command; the checker never sees it, so deny rules on that command don't fire. The exact input is withheld until a fix ships.

The utility

This is the finding that applies most widely, because it needs no parsing error at all. The checker and the shell agree on what the command is, but the "read-only" program does more than its name suggests:

  • Output operands and flags. The GNU manual for uniq documents its form as uniq [option]... [input [output]]: a second file name is where it writes. The paper's running example, uniq README.md /var/tmp/x, was allowed by six of the eight agents. sort -o and git diff --output= behave the same way.
  • Flags that run programs. ripgrep's --pre option runs a preprocessor program on each file it searches, as its user guide describes; sed and sort --compress-program have similar paths.
  • Environment variables set inline, such as GIT_TRACE or RIPGREP_CONFIG_PATH, which change what the program reads or writes.

Against 55 such cases, Continue allowed 9, Mistral Vibe 20 (despite 15 hand-written per-program guardrails), and the other six between 39 and 47.

Confinement

The third boundary is specific to Codex CLI. Its operating-system sandbox on Linux blocked every tested write when used on its own. But with allow rules configured and the session in read-only sandbox mode, a command matching an allow rule ran without the sandbox, so uniq could write outside the workspace.

Here the paper and the vendor's documentation describe the same behaviour differently. The paper calls it a "policy–sandbox inversion" and reports it as a defect. Codex's rules documentation presents rules as the way to "control which commands Codex can run outside the sandbox", and defines allow as "Run the command outside the sandbox without prompting." On the documentation's terms, an allow rule is an exemption from the sandbox by design. Either way, the practical effect is the same: an allow rule for an inspection program is not a read-only grant.

What happened with real models

To check whether these gaps matter when a model, not a test harness, writes the commands, the author drove all eight agent command-line tools with two models in containers with no network except the model API. Control runs confirmed that each agent's gate was working. The targeted effect still occurred in all 16 agent and model pairs, 14 of them under configured restriction rules rather than permissive modes.

The paper also names permissive defaults it treats separately from bypasses, such as Continue allowing shell commands in headless mode and OpenCode auto-allowing "ask" decisions in headless runs. Those are settings, not bugs, but they matter for anyone running agents unattended in CI.

The author reported the issues privately to the active vendors and to the tree-sitter-bash maintainers on 22 November, with a 90-day disclosure window, and redacted exact triggers from this version of the paper. Roo Code and Continue were already archived. We have not seen vendor responses or fixes yet, so treat the specific findings as reported, not confirmed.

The proposed fix, and its limits

The paper's own design, ShellPlan, removes the second reading. It compiles a strict subset of Bash once into a typed plan, checks each program's arguments against a list of what that program is allowed to do, and runs the plan directly with execve, without a shell. In the paper's tests it admitted none of 4,174 attack cases and kept a median gate latency of 1.28 ms per task. It also escalated more legitimate work: it completed 74 of 100 benign tasks across ten models, against 93 of 100 with no gate, with most losses in smaller models. It is a research prototype, and its code will be released after the disclosure window.

What it means for engineering and security leaders

The useful lesson is architectural. A prefix or name-based allow list answers "which program is this?", not "what will this do?". Programs that read are often a flag away from writing or executing. Any approval scheme that checks a string and then gives that string to a shell has two interpreters, and an attacker who can influence the agent's input, through a README, an issue or a build log, only needs them to disagree once.

That makes the layer underneath the approval gate the one that counts: an operating-system sandbox that applies to every command, a container or virtual machine with no credentials worth stealing, and network limits. We covered what built-in sandboxes do and don't cover in sandboxing coding agents.

Practical takeaways

  • Audit your allow lists. Remove broad entries for uniq, sort, sed, rg, find, git diff and git show, or narrow them to exact argument forms.
  • In Codex, read allow as "outside the sandbox". Prefer prompt for anything you wouldn't run unsandboxed, and test rules with codex execpolicy check.
  • Check headless defaults in every agent you run in CI or scripts, and set them explicitly.
  • Keep the sandbox on for approved commands too, and run agents with credentials scoped to the task.
  • Watch for fixes to tree-sitter-bash, Gemini CLI, Mistral Vibe, Qwen Code, OpenCode, Cline and Codex CLI over the next 90 days, and update when they land.

Sources

  1. ParseGap: Testing What Coding Agents Authorize and What Shells Execute (arXiv 2611.29546, 22 November 2026)
  2. OpenAI Codex documentation: Rules
  3. GNU Coreutils manual: uniq invocation
  4. ripgrep user guide: preprocessor (--pre)
Cookie categories

Details: Cookie Policy.