ModerateGHSA-r964-556v-776cdraft, embargoed

GHSA-r964-556v-776cStored XSS via unescaped directory name rendered in file tree and breadcrumb

Pheditor validates file names but never directory names, so an authenticated user can plant markup that executes in every other user's session as soon as they expand the folder tree.

pheditor/pheditor ·PHP ·183 ★ ·Published 09 Sep 2026 ·5 min read

Embargoed draft. This advisory is still private on GitHub. Technical details below are published here for the record; the maintainers' advisory and any CVE ID will follow once the report is disclosed.

Pheditor, a single-file PHP web editor for browsing and editing files on a server, validates file names against a strict pattern but applies no equivalent check to directory names. A directory created through the make-dir action can therefore contain an HTML payload, and that raw name is written unescaped into two independent DOM sinks: the jstree file tree and the breadcrumb. Any other user who opens the file manager and expands the folder executes the attacker's JavaScript.

01Background: one shared password, one shared origin

Pheditor is deliberately small: a single PHP file that exposes a file tree, an editor and a small set of filesystem actions behind a password. The README documents shared deployments explicitly: several people using the same password, or PASSWORD='' for a "fully trusted, isolated environment": which is how it usually gets deployed on a jump host or an internal admin box.

That deployment model is what turns a naming bug into a cross-user issue. Every authenticated user shares the same origin, the same session cookie namespace and the same filesystem view, so script executing in one browser context can act on behalf of the victim inside the application.

02Root cause: files are pattern-checked, directories are not

Saving, opening and listing files all funnel names through PATTERN_FILES. Directory creation does not. In pheditor.php, the make-dir case only checks that the caller holds the newdir permission, rejects ../ and ..\ sequences, and confirms the parent path stays inside MAIN_DIR via check_path(). The name itself is used as supplied:

case 'make-dir':
    ...
    $dir = MAIN_DIR . $_POST['dir'];
    if (check_path($dir, false) === false) { die(json_error('Invalid path')); }
    if (file_exists($dir) === false) { mkdir($dir, DEFAULT_DIR_PERMISSION); ... }

PATTERN_DIRECTORIES exists, but it is only consulted when listing entries, and by default it merely excludes names containing backup. It is not an input filter, and it never runs at creation time. A name such as <img src=x onerror=...> is a perfectly valid directory name for the filesystem and survives into the HTML response.

03Two independent sinks: jstree and the breadcrumb

Sink 1: the file tree

The GET ?path= handler returns each entry's raw name as the node text. jstree 3.3.17 inserts that text into .jstree-anchor without escaping, so a tag inside a directory name is parsed as markup and executed when the parent folder is expanded. Observed DOM after expanding the root:

<a class="jstree-anchor" ...><i class="..."></i>xss-pwned-<img src="x" onerror="window.__xp1=true"></a>

Sink 2: the breadcrumb

Clicking a tree node sets location.href to its hash. The hashchange handler decodes the fragment with decodeURI() and writes it into the breadcrumb using jQuery's .html():

var hash = decodeURI(window.location.hash.substring(1));
...
$("#path").html(hash);

The decoded directory name is therefore inserted as raw HTML in #path as well. The same payload fires a second time, without expanding anything, as soon as the victim clicks the node (observed: #path.innerHTML equals /xss-pwned-<img ...>/).

Because the two paths are separate code, escaping in only one of them would not have been sufficient. Fixing the output layer means fixing both, or sanitising once at creation time.

04Proof of concept

Verified end to end against a default instance, tag 2.1.1, commit d8bb8d5:

  1. Log in with the default password admin, or into any shared / no-password deployment as documented in the README.
  2. Create a directory named <img src=x onerror=alert(document.domain)> through the New Directory action (POST action=make-dir). The request succeeds; the name is stored verbatim on disk.
  3. The victim opens the app and expands the root folder in the file tree. A real <img> element appears inside .jstree-anchor and its onerror handler fires: JavaScript now runs in the victim's session.
  4. Variant: clicking the node renders the decoded name into the breadcrumb, which executes the payload again through the .html() sink.

No victim interaction beyond opening the file manager is required: the tree renders the root listing on load, and expanding any folder containing the malicious directory triggers the first sink.

05Impact

In a shared deployment, an attacker who can create directories executes JavaScript in every other user's browser as soon as they browse the tree. From that position the attacker can read whatever the application's API exposes and perform actions in the victim's session: edit, rename, delete and upload files: without the victim noticing.

Where a file manager is used to edit PHP or shell scripts that are served by the same host, script execution inside the application is also a step toward running code on the server, although that requires the deployment to serve the edited files.

In a strict single-admin deployment the issue degrades to self-XSS. The reporter's assessment is Moderate, which matches the shared-deployment scenario the README documents.

06Affected versions

PackageAffectedPatched
pheditor/pheditor (Composer)<= 2.1.12.1.4

The bug is present in every release before 2.1.4. The advisory is tracked as GHSA-r964-556v-776c; no CVE ID has been assigned at the time of writing.

07Remediation

  • Validate at creation time. Apply the same class of pattern check used for files (PATTERN_FILES) to directory names in the make-dir action, rejecting names that are not a plain path component.
  • Escape at the output layer. jstree parses node text as HTML, so escaping has to happen before the name is handed to the tree: either in JS when building nodes or by sanitising the name in the JSON response.
  • Stop using .html() for the breadcrumb. #path only needs text; .text() removes the second sink entirely.

Upgrading to 2.1.4 addresses the issue. Operators who cannot upgrade immediately should restrict the newdir permission to trusted accounts, which limits the attack to users who are already able to write to the filesystem anyway.

08Timeline

  1. 2026-09-09Report filed privately with the maintainers as GHSA-r964-556v-776c, including the end-to-end reproduction against tag 2.1.1.
  2. 2026-09-09Advisory accepted and marked as a draft; fix targeted for 2.1.4.
  3. PendingPublic disclosure, and CVE assignment if the maintainers request one.

09References

AG
Arthur Gurunlian @Buggs777

Vulnerability researcher working on application security, reverse engineering and fuzzing. I find, verify and responsibly disclose bugs in widely used open-source software.