Summary
Pheditor has an authenticated terminal command whitelist bypass
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=whoami
Observed result:
Command not allowed
Available commands:
ls
Bypass request:
command=ls$(printf pheditor-terminal-bypass >/lab/app/site/proof.txt)
Observed result:
proof.txt is created with the content:
pheditor-terminal-bypass
This 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 [email protected]
Untrusted input reaches a shell command, allowing arbitrary commands to run on the host. Typical impact: code execution in the application's environment.
CVE-2026-54540 has a CVSS score of 8.8 (High). The vector is network-reachable, low privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (2.0.5); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2026-54540? CVE-2026-54540 is a high-severity OS command injection vulnerability in pheditor/pheditor (composer), affecting versions <= 2.0.4. It is fixed in 2.0.5. Untrusted input reaches a shell command, allowing arbitrary commands to run on the host.
- How severe is CVE-2026-54540? CVE-2026-54540 has a CVSS score of 8.8 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of pheditor/pheditor are affected by CVE-2026-54540? pheditor/pheditor (composer) versions <= 2.0.4 is affected.
- Is there a fix for CVE-2026-54540? Yes. CVE-2026-54540 is fixed in 2.0.5. Upgrade to this version or later.
- Is CVE-2026-54540 exploitable, and should I be worried? Whether CVE-2026-54540 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-54540 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-54540? Upgrade
pheditor/pheditorto 2.0.5 or later.