CVE-2026-54540: Pheditor/pheditor Pheditor Has An Authenticated Terminal Vulnerability

HIGH
Advisory Identifier: GHSA-9643-6xjp-vx57
CVSS 8.8
CWE-78
Published
Advisory Summary

CVE-2026-54540 is a HIGH (CVSS 8.8) pheditor has an authenticated terminal vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Pheditor/pheditor libraries in the Packagist ecosystem. The issue involves pheditor has an authenticated terminal command whitelist bypass. Remediation is available by upgrading affected packages to version 2.0.5.

CVE-2026-54540 at a Glance

CVE Identifier CVE-2026-54540
GHSA Identifier GHSA-9643-6xjp-vx57
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Pheditor/pheditor
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-54540

To remediate this vulnerability, upgrade all affected Pheditor/pheditor dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

pheditor/pheditor fixed: 2.0.5
Upgrade pheditor/pheditor to 2.0.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for pheditor/pheditor

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-54540, inspect your project dependencies for Pheditor/pheditor:

inspect dependencies for pheditor/pheditor

Analyze the terminal output to locate any version of Pheditor/pheditor in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Pheditor/pheditor, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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 `$command` starts with one of the configured values in `TERMINAL_COMMANDS`. - It then passes the full command string to `shell_exec()`. Relevant logic: ```php $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`: ```php define('TERMINAL_COMMANDS', 'ls'); ``` Control request: ```text command=whoami ``` Observed result: ```text Command not allowed Available commands: ls ``` Bypass request: ```text command=ls$(printf pheditor-terminal-bypass >/lab/app/site/proof.txt) ``` Observed result: ```text 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 <shanjijian@gmail.com>

CVE-2026-54540 Affected Pheditor/pheditor Versions

1 component(s)
Fixed Versions:
2.0.5
Product / Package Ecosystem Affected Versions Fixed Version
pheditor/pheditor
Packagist
< 2.0.5
2.0.5

References

Frequently Asked Questions

What is CVE-2026-54540?
CVE-2026-54540 is a security vulnerability in Pheditor/pheditor involving Pheditor has an authenticated terminal command whitelist bypass under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Pheditor/pheditor versions are affected?
Affected versions include releases prior to 2.0.5 across affected packages: pheditor/pheditor.
What version fixes CVE-2026-54540?
Upgrading to 2.0.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pheditor/pheditor affected?
Yes, pheditor/pheditor is affected in releases prior to 2.0.5. Upgrade your dependency to 2.0.5 or later.
What is the CVSS score of CVE-2026-54540?
CVE-2026-54540 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-54540?
CVE-2026-54540 is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.).
How can I check Packagist dependencies for CVE-2026-54540?
Run the dependency tree command: 'inspect dependencies for pheditor/pheditor'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9643-6xjp-vx57",
  "modified" : "2026-07-16T20:01:05Z",
  "published" : "2026-07-16T20:01:05Z",
  "aliases" : [ "CVE-2026-54540" ],
  "summary" : "Pheditor has an authenticated terminal command whitelist bypass",
  "details" : "### Summary\n\nPheditor 2.0.4 has an authenticated terminal command whitelist bypass.\n\nThe 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.\n\n### Details\n\nTested repository:\n\nhttps://github.com/pheditor/pheditor\n\nTested commit:\n\n`62b43df7cb8956a9b0deb9bec278ca8676c890c5`\n\nAffected version:\n\nPheditor 2.0.4\n\nRelevant code in `pheditor.php`:\n\n- The terminal handler receives `$_POST['command']` and stores it in `$command`.\n- It blocks only `&`, `;`, and `||`.\n- It checks whether `$command` starts with one of the configured values in `TERMINAL_COMMANDS`.\n- It then passes the full command string to `shell_exec()`.\n\nRelevant logic:\n\n```php\n$command = $_POST['command'];\n\nif (strpos($command, '&') !== false || strpos($command, ';') !== false || strpos($command, '||') !== false) {\n    echo json_error(\"Illegal character(s) in command (& ; ||)\\n\");\n    exit;\n}\n\nforeach ($terminal_commands as $value) {\n    $value = trim($value);\n\n    if (strlen($command) >= strlen($value) && substr($command, 0, strlen($value)) == $value) {\n        $command_found = true;\n        break;\n    }\n}\n\n$output = shell_exec((empty($dir) ? null : 'cd ' . escapeshellarg($dir) . ' && ') . $command . ' && echo \\ ; pwd');\n```\n\nBecause 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.\n\n### PoC\n\nThis was reproduced locally with Docker and PHP 8.3.\n\nFor a strict test, the configured command allowlist was changed to only allow `ls`:\n\n```php\ndefine('TERMINAL_COMMANDS', 'ls');\n```\n\nControl request:\n\n```text\ncommand=whoami\n```\n\nObserved result:\n\n```text\nCommand not allowed\nAvailable commands:\nls\n```\n\nBypass request:\n\n```text\ncommand=ls$(printf pheditor-terminal-bypass >/lab/app/site/proof.txt)\n```\n\nObserved result:\n\n```text\nproof.txt is created with the content:\npheditor-terminal-bypass\n```\n\nThis shows that even when only `ls` is allowed, arbitrary shell commands can still be executed through command substitution.\n\n### Impact\n\nAn authenticated user with the `terminal` permission can bypass the intended `TERMINAL_COMMANDS` restriction and execute arbitrary shell commands as the web server user.\n\nThis affects deployments where administrators rely on `TERMINAL_COMMANDS` to restrict terminal access to a small set of safe commands.\n\nSuggested fixes:\n\n- Avoid passing user-controlled command strings to `shell_exec()`.\n- Parse the command into executable and arguments.\n- Require an exact command name match instead of prefix matching.\n- Execute without a shell, for example with an argument-array based process API.\n- If shell execution remains necessary, reject shell metacharacters comprehensively, including command substitution syntax.\n- Consider disabling the terminal feature by default.\n\nReporter credit requested:\n\nshanjijian <shanjijian@gmail.com>",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "pheditor/pheditor"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.0.5"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.0.4"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pheditor/pheditor/security/advisories/GHSA-9643-6xjp-vx57"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pheditor/pheditor"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pheditor/pheditor/releases/tag/2.0.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-78" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-07-16T20:01:05Z",
    "nvd_published_at" : null
  }
}