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:
| Binary | Weaponizable flag | Effect |
|---|---|---|
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 / -x | run prog |
php-cgi | -d allow_url_include=1 -d auto_prepend_file=... | include/run code |
wget / curl | --config, -K, -o | read config, write files |
ssh | login 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 togit rebasewith no--. A malicious branch--exec=touch${IFS}/tmp/rce_proofexecutes 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-ddirectives to the PHP interpreter. Mass-exploited by TellYouThePass ransomware within days. - Open Build Service CVE-2026-56004.
obs_scm’srevisionreacheshg update <rev>with no separator. Payload--config=hooks.pre-update=id > /tmp/idid→hgruns/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 viawgetconfig. - Home Assistant ffmpeg (patched 2026.6.2). The Wyoming
announceservice passesmedia_idtoffmpeg -i. Blocklist missed pseudo-protocols; attacker chainssubfile:/concat:byte-ranges from/bin/go2rtcto forge a valid audio header, then appendsfile:///proc/self/environto exfiltrateSUPERVISOR_TOKEN→ RCE as root via Supervisor API. - Tailscale SSH TS-2026-009. A malformed username such as
-iis 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=payloadthenrg --pre bash, and a facade-pattern tool that appendsfd -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.
Related
Sources
- OBS: command execution through Mercurial argument injection (CVE-2026-56004) · original
- Prompt Injection to RCE in AI Agents · original
- New Gogs zero-day flaw lets hackers get RCE · original
- No fix yet for critical Gogs RCE bug · original
- Critical RCE in PHP CGI (CVE-2024-4577) · original
- Your House Has an FFmpeg Problem · original
- TS-2026-009: Insecure argument handling in Tailscale SSH · original