Argument Injection

The executed binary is fixed and no shell is involved, but attacker-controlled data is placed in argv; a value that begins with - is parsed as an option, letting the attacker turn a trusted program’s own flags into code execution (CWE-88).

How it works

The app builds an argument vector (execve/ProcessBuilder/subprocess([...])) — so classic Command Injection metacharacters are inert — but it appends user input without a -- end-of-options separator. Any value starting with - is interpreted as a flag. Many ubiquitous binaries have a flag that runs an arbitrary program or writes a file:

BinaryWeaponizable flagEffect
git rebase / git am--exec=<cmd>run cmd per commit
git show / git log--format=... + --output=<file>write attacker file
hg (Mercurial)--config=hooks.pre-update=<cmd>run cmd via hook
ffmpeg-i file:///..., pseudo-protocols concat:/subfile:arbitrary file read
ripgrep--pre <prog>run prog on each file
find / fd-exec / -xrun prog
php-cgi-d allow_url_include=1 -d auto_prepend_file=...include/run code
wget / curl--config, -K, -oread config, write files
sshlogin name -i, -o ProxyCommand=option smuggling

The fix is almost always the same one line: insert -- before the user value, and reject values beginning with -.

Notable cases

  • Gogs --exec (GHSA-qf6p-p7ww-cwr9 / Metasploit module, CVSS 9.4). With “Rebase before merging” enabled, a PR’s base branch name is passed to git rebase with no --. A malicious branch --exec=touch${IFS}/tmp/rce_proof executes as the Gogs process user. Default config ships with open registration + unlimited repo creation, so effectively unauthenticated; >2,400 servers exposed. Same family as CVE-2024-39930/39932/39933, CVE-2026-26194.
  • PHP-CGI CVE-2024-4577 (RCE, all Windows PHP-CGI; ~34% of cloud environments with Windows PHP affected). Windows “Best-Fit” encoding maps a soft hyphen to -, letting an unauthenticated attacker re-introduce the CVE-2012-1823 argument-injection (?%ADd+allow_url_include%3d1...) to pass -d directives to the PHP interpreter. Mass-exploited by TellYouThePass ransomware within days.
  • Open Build Service CVE-2026-56004. obs_scm’s revision reaches hg update <rev> with no separator. Payload --config=hooks.pre-update=id > /tmp/idid → hg runs /bin/sh -c "id > /tmp/idid" on the build server (supply-chain critical). Second of its family; CVE-2024-22033 was the same root cause via wget config.
  • Home Assistant ffmpeg (patched 2026.6.2). The Wyoming announce service passes media_id to ffmpeg -i. Blocklist missed pseudo-protocols; attacker chains subfile:/concat: byte-ranges from /bin/go2rtc to forge a valid audio header, then appends file:///proc/self/environ to exfiltrate SUPERVISOR_TOKEN → RCE as root via Supervisor API.
  • Tailscale SSH TS-2026-009. A malformed username such as -i is handled as an SSH option, granting root. Fixed in 1.98.9.
  • AI coding agents (Trail of Bits). “Safe command” allowlists validate the binary but not its flags. One-shot Prompt Injection → RCE via go test -exec 'bash -c ...', git show --format=<hex> --output=payload then rg --pre bash, and a facade-pattern tool that appends fd -x=python3. The same payloads fire from code comments, README files and logs, not just chat.
  • GitLab “Git flag injection — local file overwrite to RCE” — $12,000 HackerOne bounty, a canonical git argument-injection chain.

Defenses

  • Append -- (end of options) before every user-controlled argument; reject values starting with -.
  • Prefer APIs that cannot interpret flags (pass the value via stdin, environment, or a fixed positional after --).
  • For agent/allowlist designs, validate the full argument set, not just the command name, and sandbox execution — flag space is too large to denylist.

Sources