The Allowlist Checked the Program, Not the Environment: How Shell Built-ins Bypassed an Agent's Command Gate (CVE-2026-22708)
DEV Community

The Allowlist Checked the Program, Not the Environment: How Shell Built-ins Bypassed an Agent's Command Gate (CVE-2026-22708)

TL;DR - CVE-2026-22708 (published January 14, 2026, CVSS 4.0 score 7.2, CWE-78) describes a flaw in the terminal allowlist of the Cursor agentic editor, fixed in version 2.3.

The gate checked which executable a command would launch, but treated shell built-ins such as export, alias, typeset and declare as implicitly safe. Those built-ins do not run a program. They change the environment that the next approved program runs in.

Set PAGER to a script, then run git branch, and the allowlisted command launches the attacker's code. The lesson for anyone building an agent action gate: a gate that approves commands one at a time, by name, cannot see state that carries from one command to the next. Environment, aliases, functions, working directory and shell startup files are all state.

Below is a small illustrative model (no real shell is invoked) comparing three gate designs on 12 sessions. The name-only gate passes 8 of 8 attack sessions. A gate that treats environment-mutating built-ins as actions passes 0 of 8 and blocks one of four benign sessions. A denylist of variable names passes 1 of 8, and the one that slips through is an alias.

What exactly did the Cursor allowlist miss?

An agentic coding editor can run terminal commands for you. To keep a human in the loop without prompting for every ls, most tools offer an allowlist or an "auto-run" mode: commands whose executable is on the list run without a prompt, and everything else asks first.

The published record for CVE-2026-22708 says the allowlist logic examined external binaries and ignored shell built-ins. The record names export and alias as examples, and the researcher's write-up adds typeset and declare.

A built-in is not a separate executable. It is handled by the shell process itself, so a check keyed on "which program is being launched" has nothing to look at. That would be harmless if built-ins could not change what happens next. They can.

The environment of a shell session is inherited by every program the shell starts afterwards, and many ordinary programs read environment variables as instructions:

Variable Who reads it What it can do
PAGER git, man and others git runs the named program to display long output
PATH the shell decides which git or python3 actually runs
PYTHONWARNINGS, BROWSER the Python runtime and standard library can be chained to reach a launcher
PERL5OPT perl injects interpreter options

The researcher's write-up (first published January 14, 2026 and updated in July 2026) groups the resulting attacks into three kinds:

  • One-click. The user approves something that looks safe, and a later allowlisted command such as git branch runs attacker-chosen code through PAGER.
  • Zero-click. No approval at all. The write-up describes shell syntax tricks such as a zsh parameter expansion flag that evaluates a default value as code, and a redirection that writes to ~/.zshrc.
  • Chained. A Python chain through PYTHONWARNINGS, BROWSER and PERL5OPT.

The timeline in the write-up: reported to the vendor on August 11, 2025, acknowledged in August, described by the vendor as a "systemic issue" in September, and fixed in January 2026.

The vendor's own guidance, quoted in the write-up, is that the allowlist is best-effort and bypasses are possible, and that users should never use "Run Everything" mode.

Why does checking each command by name fail?

Because the unit of approval is wrong. The gate answers "is this command safe?" when the real question is "is this command safe given everything that ran before it?"

Think of the session as a state machine. Each command is a transition. A command like git branch is only safe in states where PAGER is unset or points at a real pager. The allowlist looks at the transition label and never at the state.

This is the same family of mistakes as an approval cache keyed by tool name instead of arguments: the check is cheap and local, and the thing it fails to see is context. It also resembles validating a path string instead of the path the operating system will actually open. In each case, the gate and the executor disagree about what the action is.

There are three ways to close the gap:

  1. Make state changes into actions. Treat any built-in that mutates the environment as a gated action, with its own approval.
  2. Constrain the state instead of inspecting it. Run each command with a fixed, minimal environment, so that nothing set in an earlier step can reach the next one.
  3. Isolate execution. Put the whole session in a container or VM, so that even a poisoned PAGER can only reach what the sandbox can reach.

The vendor fix moves in the first direction. The sections below show why the second and third matter as well.

How do the gate designs compare? A small model

The following script is an illustrative model. It does not run a shell and it does not use real exploit payloads. It encodes 12 sessions as lists of steps. Eight are attack-shaped (an environment-changing step followed by an allowlisted command that would read it) and four are benign. Then it runs three gate designs over them.

# Illustrative model: an allowlist gate that only inspects executable names.
# No real shell is invoked. Each "session" is a list of (command, kind) steps.
BUILTINS = { "export" , "alias" , "typeset" , "declare" , "source" }
ALLOW = { "git" , "python3" , "ls" }
POISON_VARS = { "PAGER" , "PATH" , "PYTHONWARNINGS" , "BROWSER" , "PERL5OPT" , "GIT_EXTERNAL_DIFF" }
# (steps, is_attack)
SESSIONS = [
  ( [ ( "export PAGER=./x.sh" , "env" ) , ( "git branch" , "exe" ) ] , True ) ,
  ( [ ( "export PATH=./bin:$PATH" , "env" ) , ( "git status" , "exe" ) ] , True ) ,
  ( [ ( "alias git=./x.sh" , "env" ) , ( "git log" , "exe" ) ] , True ) ,
  ( [ ( "export PYTHONWARNINGS=all:0:x.y:0:0" , "env" ) , ( "python3 run.py" , "exe" ) ] , True ) ,
  ( [ ( "export BROWSER=./x.sh" , "env" ) , ( "python3 run.py" , "exe" ) ] , True ) ,
  ( [ ( "export PERL5OPT=-Mx" , "env" ) , ( "git gc" , "exe" ) ] , True ) ,
  ( [ ( "export GIT_EXTERNAL_DIFF=./x.sh" , "env" ) , ( "git diff" , "exe" ) ] , True ) ,
  ( [ ( "typeset PAGER=./x.sh" , "env" ) , ( "git branch" , "exe" ) ] , True ) ,
  ( [ ( "git status" , "exe" ) ] , False ) ,
  ( [ ( "ls" , "exe" ) ] , False ) ,
  ( [ ( "python3 run.py" , "exe" ) ] , False ) ,
  ( [ ( "export LANG=C" , "env" ) , ( "git log" , "exe" ) ] , False ) ,
]
def var_of ( cmd ) :
  return cmd . split ( None , 1 ) [ 1 ] . split ( "=" , 1 ) [ 0 ] if " " in cmd else ""
def gate_names_only ( step ) :
  cmd , kind = step
  return True if kind == "env" else cmd . split ( ) [ 0 ] in ALLOW
def gate_builtin_aware ( step ) :
  cmd , kind = step
  if kind == "env" :
    return False # env-mutating built-ins need approval
  return cmd . split ( ) [ 0 ] in ALLOW
def gate_scrubbed_env ( step ) :
  cmd , kind = step
  if kind == "env" :
    return var_of ( cmd ) not in POISON_VARS # approve only harmless vars
  return cmd . split ( ) [ 0 ] in ALLOW
def run ( gate ) :
  atk_ok = ben_ok = 0
  for steps , is_atk in SESSIONS :
    passed = all ( gate ( s ) for s in steps )
    if is_atk and passed :
      atk_ok += 1
    if ( not is_atk ) and passed :
      ben_ok += 1
  return atk_ok , ben_ok
for name , g in [ ( "names_only" , gate_names_only ) , ( "builtin_aware" , gate_builtin_aware ) , ( "var_denylist" , gate_scrubbed_env ) ] :
  a , b = run ( g )
  print ( f "{name:14s} attacks_passed={a}/8 benign_passed={b}/4" )

Output from running it:

names_only     attacks_passed=8/8 benign_passed=4/4
builtin_aware  attacks_passed=0/8 benign_passed=3/4
var_denylist   attacks_passed=1/8 benign_passed=4/4

Each number teaches something different.

Name-only gate: 8 of 8 attacks pass. Every step is either an allowlisted executable or a built-in that the gate does not look at. This is the design the CVE describes, reduced to its essence. Benign sessions also all pass, which is exactly why this design feels fine in daily use.

Built-in-aware gate: 0 of 8 attacks pass, 3 of 4 benign sessions pass. Every environment-mutating built-in requires approval. This is safe but has a usability cost: the one benign session that sets LANG=C now asks the user. That cost is real, because a gate that interrupts too often trains people to click yes, and a click-through habit is its own vulnerability.

Variable denylist: 1 of 8 attacks pass, 4 of 4 benign sessions pass. This is the tempting middle path: approve environment changes unless the variable is on a list of dangerous names. It nearly works, and the failure is instructive. The session that gets through is alias git=./x.sh. An alias is not a variable, so a rule written around variable names does not see it. Real shells have more state of this kind than any list will cover: functions, PATH entries, startup files, loader variables and tool-specific option variables. A denylist is a bet that you have enumerated every way a program can be redirected, and the CVE record, with its mix of PAGER, PYTHONWARNINGS, BROWSER and PERL5OPT, shows how long that list gets.

The numbers above come from a model I wrote, not from measurements of any product. They show the shape of the trade-off, not a ranking of real tools.

What should an agent builder do instead?

A practical checklist, ordered from cheapest to strongest.

  1. Gate state changes, not just program launches. List every built-in your shell tool can reach (export, unset, alias, unalias, typeset, declare, source, ., cd, set, eval) and route each through the same approval path as a program.
  2. Scrub the environment per command. Spawn each command with an explicit environment built from a short known-good list. Do not inherit the interactive shell's variables. Then an earlier step cannot poison a later one, because there is no shared state to poison.
  3. Do not keep a long-lived shell for the agent. A persistent shell is a state accumulator. A fresh process per command is not, and the cost is small compared with the risk.
  4. Run the agent in a sandbox that matches the blast radius you accept. If a poisoned variable can only reach a disposable container, a bypass becomes an annoyance and not a breach.
  5. Keep a human in the loop for anything that writes to shell startup files. A write to ~/.zshrc turns a one-time event into a permanent one.
  6. Log the environment delta. If an agent session ends with a different environment than it started with, that is a signal worth surfacing.
import os , subprocess
SAFE_ENV = { "PATH" : "/usr/bin:/bin" , "LANG" : "C.UTF-8" , "HOME" : os . environ . get ( "HOME" , "/tmp" ) }
def run_gated ( argv , allow ) :
  if argv [ 0 ] not in allow :
    raise PermissionError ( f "not allowlisted: {argv[0]}" )
  # Fresh process, fixed environment, no shell, no inherited PAGER or PATH.
  return subprocess . run ( argv , env = SAFE_ENV , shell = False , capture_output = True , text = True , timeout = 30 )

Two properties matter in that snippet. shell=False removes the shell and with it every built-in, alias and expansion rule. And env=SAFE_ENV removes inherited state. Together they make the name-only check sound, because the name is now the whole story.

What should you do as a user of an agentic editor today?

Update to a version that includes the fix. For Cursor, the record lists affected versions below 2.3 and the fixed version as 2.3. Do not use any mode that runs everything without asking, and check that your allowlist is not effectively "allow all".

Treat the allowlist as best-effort convenience and not as a security boundary, which is the vendor's own wording. If you suspect an older version was exposed, review shell history files for unexpected export or alias lines, and review ~/.zshrc and ~/.bashrc for edits you did not make. Prefer isolated environments for sessions that process untrusted repositories or web content.

FAQ

What is CVE-2026-22708 in one sentence? A command allowlist in the Cursor editor checked executables but not shell built-ins, so a prompt-injected agent could use export or alias to poison the environment and make an approved command run attacker code. It is fixed in version 2.3.

Why are shell built-ins dangerous if they do not run programs? They change the environment, aliases and functions that later programs inherit. Many programs treat environment variables as instructions, for example git running whatever PAGER names.

Is an allowlist useless, then? No. It removes friction and catches obvious mistakes. It is just not a security boundary on its own. Pair it with a scrubbed per-command environment and a sandbox.

Can a denylist of dangerous variables fix this? It helps and still leaves gaps. In the model above, a variable denylist stops 7 of 8 attack sessions and misses the one that uses alias. Enumerating every redirecting mechanism is the hard part.

Does shell=False solve the problem? It removes shell built-ins and expansion, which is a large part of the surface. You still need a fixed environment, because programs such as git and python3 read their own variables.

Was it exploited in the wild? The sources I read describe a proof of concept and an unproven exploit-status rating. They do not report in-the-wild exploitation.

Links

Further reading

  • One Yes, Every Shell Command: How a Tool-Name Approval Cache (CVE-2026-56074) Turns a Click Into a Standing Grant (earlier post, same series)
  • The Server Only Listened on 127.0.0.1: How DNS Rebinding Turned Local MCP Servers Into Web-Reachable Tools (earlier post, same series)
Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.