GHSA-g3hq-hphg-8fhh: Pheditor: Terminal command-allowlist bypass via argument injection leads to RCE — surviving vector after the metacharacter-sanitization fixes
Summary
pheditor's terminal feature restricts callers to an allowlist of commands (TERMINAL_COMMANDS) and rejects shell metacharacters. The allowlist is enforced as a PREFIX match with no argument validation, and the allowlist includes binaries that grant arbitrary command execution through their own options (find, git, php, tar, grep). A caller can therefore run any command using only allowlisted binaries and no rejected metacharacter, escaping the allowlist restriction the terminal feature relies on.
Relationship to the prior terminal advisories (this is a surviving, distinct vector)
The prior terminal advisories were all shell-metacharacter injections: GHSA-9643-6xjp-vx57 ($()), GHSA-wg4w-wr5q-6vjc (|, backtick, newline), GHSA-jvc5-58fv-w8cq (; via the dir field). The current code rejects those characters. This report is a different class — CWE-88 argument injection through an allowlisted binary's flags — which the metacharacter denylist does not address.
Root cause (HEAD, v2.0.6)
In the terminal action handler of pheditor.php:
1. :588 rejects &, ;, |, $, backtick, \n, \r. It does NOT reject space, -, {, }, +, /, ..
2. :595-605 checks the command against TERMINAL_COMMANDS (defined :25: ls,...,php,...,git,find,grep,...,tar,...,composer,exit) using a PREFIX match: strlen($command) >= strlen($value) && substr($command, 0, strlen($value)) == $value. There is no word boundary and no validation of the arguments that follow.
3. :617 runs the command through the shell unchanged: shell_exec((empty($dir) ? null : 'cd ' . escapeshellarg($dir) . ' && ') . $command . ' && echo \ ; pwd').
So a command beginning with an allowlisted binary, carrying a code-exec flag, and containing none of the rejected characters reaches shell_exec intact.
Proof of concept (reproduced)
POST to the terminal action with:
command = find . -maxdepth 0 -exec touch /tmp/PWNED {} +
dir = (any)
This contains no rejected metacharacter, prefix-matches the allowlisted find, and find -exec runs an
Details
Original advisory: https://github.com/advisories/GHSA-g3hq-hphg-8fhh
More from GitHub Security Advisories
- mediumGHSA-jr6p-8pjj-mfx6: Capsule has an incomplete fix of CVE-2026-22872: TenantResource RawItems and Generators s…2026-07-31
- mediumGHSA-68cj-mvg9-rgm2: Capsule: CapsuleConfiguration NodeMetadata regex fields lack webhook validation, allowing…2026-07-31
- mediumGHSA-ff84-5f28-78qj: re2: Out-of-bounds heap read in `exec`/`test`/`match` via attacker-influenced `lastIndex`…2026-07-31
- mediumGHSA-6hxr-mr5r-9836: re2: Global `String.prototype.match` with an empty-matchable pattern never advances → inf…2026-07-31
- mediumGHSA-x83g-979r-f5fh: Sylius Mollie Plugin has unauthenticated IDOR that leaks order token and customer PII2026-07-31