//nefariousplan

Argv List Is Not Sanitization

Code passes attacker-controlled values to a subprocess by constructing the call as an explicit argv list rather than as a shell string, reading the choice of list form over `shell=True` as the threat model's full defense. The shell does not run; the receiver binary's own option-versus-positional parser does. List elements that begin with `-` present to the receiver as options regardless of what the calling code intended. The fix is the receiver's documented end-of-options separator (typically `--`) inserted before any attacker-controlled positional slot, or a value-shape predicate that rejects option-shaped inputs. The list form forecloses shell injection. It does not foreclose argument injection.

The argv list form stops the shell. subprocess.run([...]) instead of subprocess.run("...", shell=True). child_process.execFile(cmd, [args]) instead of child_process.exec(...). spawn(cmd, [args]) instead of spawn('/bin/sh', ['-c', ...]). The runtime hands the list to the operating system's execve; no shell parses the command line, no field separator splits on whitespace, no glob expands, no backtick invokes a subshell. The language's own documentation names the migration as the fix for shell injection. The project's CI linter flags exec with a user value as a blocking finding. The commit message that lands the migration says "harden child process invocation."

The shell does not run. The receiver binary does.

The receiver has its own argument parser. git's parser treats any list element whose first byte is - as an option before it considers it a positional, and git's documented --upload-pack=<program> option runs the named program as the pack helper on local and SSH transports. The list form forecloses the interpreter the developer was taught to defend against. The interpreter behind it, the receiver's own getopt, reads the list elements through a grammar whose significant alphabet is one byte: the leading -.

Mechanism

The mechanism has three parts. A subprocess invocation constructed as a list of pre-tokenized arguments. An attacker-controlled value placed in a positional slot without a preceding end-of-options separator. A receiver binary whose own argument parser classifies list elements by their leading byte rather than by the caller's intent.

The list form is a correct, complete defense against the POSIX shell. The shell's job is to tokenize a command string into the argv the operating system will receive. When the application constructs the argv itself, the shell has nothing to tokenize; execve takes the array verbatim and the receiver sees exactly the tokens the caller assembled. Shell metacharacters inside a list element remain as literal bytes in that element, and the receiver reads them as bytes of a filename, a branch name, or a URL. The entire class of CVEs that end with ; rm -rf / inside a backtick, a subshell, or a command substitution closes against this form.

The receiver is the next parser in the chain. For git, that parser is getopt-style: the first byte of each list element is checked against -, and if it matches, the token's interpretation flips from "positional argument of the current subcommand" to "option whose name is parsed until the next = or whitespace." git's manual enumerates options with side effects that reach outside the parse. --upload-pack=<program> runs the named program as the pack helper on local and SSH transports. --exec=<program> sets the remote shell on git push. --config writes to the per-invocation configuration. An attacker-controlled value whose first byte is - presents to git as one of those options. The call site's intent that the value be a commit SHA, a branch name, or a URL is not an input to git's parse; the value's first byte is.

In each live exhibit of this class the author had completed the migration the language's documentation recommends and read the migration as the threat model's complete defense. Prefect's GitRepository (CVE-2026-5366) stores commit_sha and directories verbatim and places them into ["git", "fetch", "origin", self._commit_sha], ["git", "checkout", self._commit_sha], and ["git", "sparse-checkout", "set", *self._directories]. The 3.6.25 patch closes the commit_sha path with a value-shape predicate (re.match(r'^[0-9a-fA-F]{4,64}$', commit_sha)) and the directories path with the structural -- separator (['git', 'sparse-checkout', 'set', '--', *self._directories]) plus a UserWarning. The same diff applies two different defenses to two different paths; the fact that both defenses existed in git's own documentation years before the CVE is the signature of the class. degit (CVE-2026-11572) ships the same shape on the same binary six weeks after its own migration from child_process.exec to child_process.execFile. PR #410 converted the ls-remote and clone call sites to argv-list form, foreclosing /bin/sh -c evaluation of the attacker-controlled user capture. PR #429, six weeks later, added the end-of-options separator to the ls-remote call: ['git', 'ls-remote', '--', repo.url]. The first patch read the migration as complete. git's getopt parser kept running.

The fix family is two primitives, both documented in the receiver's own manual. The structural primitive is the receiver's end-of-options separator (typically --, standardized by the POSIX utility syntax guidelines and present in GNU getopt, Python's argparse, Ruby's OptionParser, Go's flag, and most CLI frameworks that read from argv). Inserted into the list before any attacker-controlled positional slot, it instructs the receiver's getopt loop to stop option parsing and treat every subsequent element as a positional regardless of its leading byte. The semantic primitive is a value-shape predicate at the point the value becomes attacker-controlled: a strict allowlist of value shapes (an anchored hex regex for commit refs, a scheme and host allowlist for URLs). Either primitive closes the class at one call site. Neither closes it at the sibling call site in the same module.

This pattern distinguishes itself from The Shell Was Not The Sink at the presence of a sanitizer function. That pattern requires a named sanitizer function (escapeshellarg, htmlEncode, OracleCodec) whose name encodes an interpreter the destination is not; the signature at the fix is often a renamed function. This pattern has no sanitizer function at the call site. The defense is a structural choice (list form, execFile, spawn with an array) that forecloses one interpreter by not running it, and the destination is the receiver whose own parser runs regardless. From Quote Wrap Is Not Escape at the primitive the developer reached for: that pattern is typed quote bytes substituting for a function call; this pattern is a structural form substituting for consideration of the receiver's grammar. Both patterns share the shelf of "the mechanism the developer chose addresses an interpreter different from the sink the attacker's bytes reach."

Exhibits

CVE-2026-5366: Prefect's GitRepository Skipped The End-Of-Options Separator The Same Patch Added One Function Down. CVE-2026-5366 is the subprocess-list-versus-getopt instance of the pattern. Prefect's GitRepository stores commit_sha and directories verbatim and places them into ["git", "fetch", "origin", self._commit_sha], ["git", "checkout", self._commit_sha], and ["git", "sparse-checkout", "set", *self._directories]. The argv form is correct against shell=True; the receiver, git, has its own getopt-style parser that reads any leading - as an option. --upload-pack=/bin/sh -c '...' is a documented git option that launches the named program as the pack helper on local and SSH transports, which lands as code execution on the worker. The 3.6.25 patch closes the commit_sha path with a value-shape predicate (re.match(r'^[0-9a-fA-F]{4,64}$', commit_sha)) and the directories path with the structural -- separator (['git', 'sparse-checkout', 'set', '--', *self._directories]) plus a UserWarning. The same diff applies the two defenses to different paths; the git fetch origin and git checkout invocations on the commit_sha path never receive --, which the patch's own choice on sparse-checkout proves was available.

Boundaries

Not every "sanitizer applied to the wrong destination" bug is this pattern. The Shell Was Not The Sink covers a sanitizer function whose name encodes one interpreter (escapeshellarg for POSIX sh, htmlEncode for HTML, OracleCodec for Oracle) applied to a value that flows to a different interpreter (rrdtool's batch reader via proc_open, ExifTool's stdin, a MySQL JDBC URL). The sanitizer fires; its grammar is correct for its named interpreter; the destination's alphabet is different. The fix is a renamed or newly introduced function whose name encodes the real destination. This pattern has no sanitizer function at the call site. The defense is a structural choice (list form, execFile, spawn with array) that forecloses the shell by not running one. The receiver's argument parser is not a destination with a different escape alphabet; it is an interpreter the list form never attempted to describe.

Not every typed-quote shell injection class is this pattern. Quote Wrap Is Not Escape covers code that reaches for a literal apostrophe or double-quote byte typed into the source-language string literal in place of calling the destination's escape primitive. The data path has no sanitizer function and no structural defense; the only mechanism between the attacker and the shell is a byte the typist encoded. This pattern requires the structural defense to be present and to work: shell=True has been removed, exec has been replaced by execFile, and the shell does not run. The CVE's destination is the receiver's own argument parser running after the shell is out of the chain. Both patterns sit on the shelf of "the mechanism the developer chose addresses an interpreter different from the one that handles the attacker's bytes," and the distinguishing fact is whether the shell is in the chain at all.

Not every "receiver option injection" instance is this pattern. Convention Is The Allowlist covers cases where a specification, RFC, or framework convention implies a constrained set of values the implementation never installed; the gap is at the spec's silence about the boundary. The argv-list case is not spec-silence. git's own manual documents -- as the end-of-options separator in the output of git help git, documents --upload-pack and --exec as options with program-execution side effects, and ships the structural fix (--) in every subcommand's parse table. The receiver names both the attack and the defense. The gap this pattern names is at the caller's model of the receiver's grammar, not at the receiver's documentation. The patch's choice between -- and a value-shape predicate is the patch author acknowledging which tool from the receiver's own kit they should have been using at the call site.

Defender playbook

Enumerate every subprocess-with-list call site in the codebase (subprocess.run([...]), execFile, spawn with array, os/exec.Command, Ruby's kernel system with array). For each, identify the receiver binary and read its manual for the end-of-options separator (usually --) and the subset of options whose side effects reach outside the process: program execution (--upload-pack, --exec), file write (--output, -o), network destination (--url, -u), environment injection (--config env=). For every attacker-controlled positional slot, confirm the call site inserts -- before the slot or applies a value-shape predicate strict enough to reject any leading - byte. The migration from shell=True to a list form is step one; the receiver's getopt parser is the step the migration did not address.

When a value-shape predicate is the chosen defense, bring the receiver's full alphabet of option prefixes to the test matrix. git reads - and --, and via --config it reads =. GNU getopt also reads + as a mode-set prefix in some modes. Ruby's OptionParser reads - as a short-option prefix. A predicate of the form value[0] != '-' is not sufficient; the regex must anchor at both ends (^[0-9a-fA-F]{4,64}$ for a commit ref, ^https?://[^/]+/ for a URL) and must exhaustively describe the accepted shape rather than reject the one byte the demonstrated PoC used. Prefect's patch chose the anchored hex regex for commit_sha; the next PoC class on this code path is any receiver option a hex string happens to shadow.

When -- is the chosen defense, verify its placement at every call site invoking the same receiver, not only the one named in the PoC. The Prefect patch that inserted -- into ['git', 'sparse-checkout', 'set', '--', *self._directories] is the patch that proved -- was available on the git binary the module was shelling out to; the sibling calls to git fetch origin and git checkout in the same module that do not receive -- are the next exhibit. Grep the project for the receiver binary name across every subprocess call and confirm each positional slot that reads an attacker-controlled value is preceded by the separator. The same audit applies to degit, where the ls-remote call received -- in PR #429 and the clone call, written on the same day in the same migration PR, did not.

Audit patches whose diff message describes the fix as "migrate exec to execFile," "switch to list form," "remove shell=True," or "harden child process invocation." Read the full patch, not the message. A migration to argv-list form is the baseline the pattern assumes is already present; the CVE lands on what the migration did not do. The second patch in the file (the one adding -- or a value-shape predicate) is typically the one the advisory names, and the first patch (the list-form migration) is often filed in a release-note section titled "linter cleanup," "code quality," or "resolve remaining security/detect-child-process findings," leaving no commit-message signal of the gap that was left.

Kinship

The Shell Was Not The Sink. Siblings on the "the defense addressed a different interpreter than the sink" shelf. The Shell Was Not The Sink names the case where a sanitizer function with a destination-encoding name (escapeshellarg, htmlEncode, OracleCodec) fires correctly for its named interpreter, and the destination is a different interpreter with a different alphabet; the signature at the fix is a renamed function. This pattern names the case where the "defense" is not a function at all but a structural choice (argv list over shell string, execFile over exec, spawn with array over /bin/sh -c) that forecloses the shell by not running one, and the sink is the receiver binary's own argument parser running after the shell is out of the chain. The two patterns answer the same question (which interpreter did the defense actually describe) from opposite ends: the sanitizer-function end and the no-function-at-all end.

Gate Narrower Than Sink. Adjacent at the two-parsers axis. Gate Narrower Than Sink names two matchers that were written to describe the same syntactic object, where the gate's grammar is strictly contained within the sink's grammar and inputs in the gap flow through unfiltered. Both matchers try to describe the same thing; one just under-reads. This pattern is one step further off that shelf: the "defense" (the argv list form) does not try to describe the receiver's option grammar at all. The list form was written to foreclose a different interpreter entirely, and the receiver's getopt was never in its design brief. The two patterns bracket "the defense does not match the sink" from different directions: Gate Narrower Than Sink from inside the same grammar, this pattern from outside it.

The shell does not run. The next parser does.