The detektd BriefNo. 16 · 9 Oct 2026
AI security19 Aug 20266 min read

The AI assistant blind spot: who's actually allowed to touch your infra

CVE-2026-22708: in Cursor, a plain README or an issue comment was enough to mutate an environment variable and hijack a command the allowlist had already approved, something as ordinary as git branch.

by detektd team

Backlit keyboard in the dark, close-up on the command and option keys
Photo: rawpixel · CC0 · rawpixel

Cursor's Auto-Run mode exists for one simple reason: stop asking for confirmation on every command. An agent working on a project runs dozens of commands per task: checking repo state, running tests, installing a dependency. Approving them one by one quickly becomes unbearable. So Cursor offers an allowlist: you approve once a list of commands you consider safe (git status, npm test, git branch...), and the agent runs them afterward without checking back with you.

CVE-2026-22708, published under security advisory GHSA-82wg-qcm4-fp2w, shows why that trust was misplaced. Before version 2.3, when the agent ran in Auto-Run with the allowlist enabled, certain shell built-in commands could run without being on the allowlist and without asking for approval.

External commands and built-ins

To understand the flaw, you need to tell two families of commands apart. git, npm or curl are external programs: the shell finds them on disk and launches them in a new process. Other commands, "built-ins", are part of the shell itself: the ones that set an environment variable, create an alias or change directory. They don't launch any program: they change the state of the shell in which every following command will run.

Cursor's allowlist checked external commands. Built-ins weren't subject to the same check. Yet many programs, git first among them, adapt their behavior to environment variables: where to look for their configuration, which helper programs to call. Changing the environment therefore means being able to change what an approved command will do.

The command's name isn't the command

The attack scenario follows directly. The allowlist checks which command is about to run, not in which environment. An attacker who can get text in front of the agent (a README, a dependency file, a GitHub issue comment, in other words indirect prompt injection) can get it to run a built-in that silently mutates an environment variable. No approval is requested. The next command is on the allowlist. But with a poisoned environment, something as ordinary as git branch runs the attacker's code.

Untrusted text (README, dependency, issue)
Shell built-in: variable changed without approval
Approved command (e.g. git branch)
Attacker's code runs

No alert fires. As far as Cursor is concerned, an approved command just ran normally. As far as the developer is concerned, the agent just listed the repo's branches. That's what makes the flaw so hard to spot: it leaves no trace in the interface.

A lesson sudo had already learned

The problem is nothing new. Unix administrators have known it for decades through sudo, which exists precisely to allow certain commands for certain users: an allowlist. And sudo had to solve exactly the same question: if users can pass their environment variables to an allowed command, they can change its behavior. That's why sudo resets the environment by default (the env_reset option) and enforces a controlled program search path (secure_path).

Coding agents reinvented the allowlist without carrying over that lesson. And unlike a human sudo user, an agent can be manipulated by any text it reads.

Not an isolated case

CVE-2026-22708 didn't arrive alone. In the same period, two neighboring flaws were fixed in Cursor: CVE-2026-26268, an escape through git hooks (scripts git runs automatically at certain steps), and CVE-2026-21523, a TOCTOU race condition ("time of check to time of use"): the state that was checked is no longer the one in use at execution time.

All three share the same structural weakness: a permission model that verifies a command, a path or an identity at one point in time, with no guarantee the surrounding environment hasn't changed between the check and the execution. Docker even devoted a post to the theme with an explicit title: "the command you already approved".

  • An allowlist checks an identity (a command's name), not an intent.
  • It assumes the execution environment is trustworthy, an assumption a single text file can break.
  • It doesn't cover the gap between when a command is approved and when it actually runs.

What a solid allowlist has to control

An allowlist that compares the start of a command line against a list of names starts with a structural handicap: the line then goes through a shell, which has its own grammar. Chaining, subcommands, redirections, variables: a single "allowed" line can hold far more than one command. CVE-2026-22708 exploited another facet of the same problem (the shell's state between two commands), but the lesson is the same: the shell interprets, and that interpretation is what needs controlling.

Tools that run commands safely do the opposite: they don't go through a shell. They launch an executable directly, by its absolute path, with a list of separate arguments, a fixed working directory, a time limit, and above all an environment built explicitly rather than inherited. It's the same principle as sudo's env_reset option, applied to code:

Run a command without a shell, with a minimal environment
import { execFile } from "node:child_process";
import { homedir } from "node:os";

execFile(
  "/usr/bin/git",                     // absolute path: no PATH lookup
  ["branch", "--list"],               // arguments, never a shell string
  {
    cwd: repoDir,
    timeout: 10_000,
    env: { PATH: "/usr/bin:/bin", HOME: homedir() },  // built, not inherited
  },
  callback,
);

That pattern closes the CVE-2026-22708 class of flaws: no variable set by a previous command can reach the next one, since every execution gets a fresh environment. The same result is available on the command line with env -i, which starts a program with an empty environment:

Same idea in the shell
env -i PATH=/usr/bin:/bin HOME="$HOME" git branch --list

The repository itself is untrusted input

One point remains that CVE-2026-26268 brings to light: git reads the local configuration of the repository it runs in, and that configuration can name programs to run automatically; hooks are the best-known example. Opening an untrusted repo and running git in it, even a read-only command, is therefore not neutral. Git has dealt with this before: in 2022, CVE-2022-24765 led to the safe.directory option (Git 2.35.2), which makes git refuse by default to use repositories owned by another user on the system. For an agent, the equivalent is to treat every freshly cloned repo as untrusted input, just like a README.

The real question: what the agent can reach

The fix has shipped since Cursor 2.3, and that's the first thing to check. But the lesson goes beyond this flaw. On a developer's machine, the agent's shell usually has access to everything the developer has: cloud credentials, SSH keys, npm or GitHub tokens, sometimes a connection to the production database. A bypassed allowlist doesn't give access to "the agent": it gives access to all of that.

  1. Update Cursor (2.3 or later). Until then, disable Auto-Run or require confirmation for every shell command.
  2. Have the agent work in a separate environment (a devcontainer, a virtual machine) that doesn't hold your personal credentials.
  3. Never leave production credentials on a development machine; prefer short-lived access, granted on demand.
  4. Be especially careful with Auto-Run on a freshly cloned repo or a new dependency: that's exactly where untrusted text hides.

The right reflex

Before approving an allowlist, ask the opposite question: if this command ran something other than what I think, what could it reach from this shell? If the answer includes production, the problem isn't the allowlist.

More in this section

The AI assistant blind spot: who's actually allowed to touch your infra | detektd