Documents & Files: path traversal in file rename => stored XSS via SVG at web root
Description
- Project: Admidio (membership management system)
- Commit tested: 9c21e94d15ae83818d0a6a33e0caef46763af901 (version 6.0.0)
- Vulnerability type: Path traversal (CWE-22) leading to stored Cross-Site Scripting (CWE-79)
- Estimated severity: Medium–High
- Status: Confirmed dynamically in an isolated local Docker environment (127.0.0.1 only; no third-party system contacted)
Summary
The "rename file" action of the Documents & Files module does not validate the user-supplied new file name. An authenticated user who has upload rights in any one documents folder (not a full administrator) can rename an uploaded file to a name containing ../ sequences. The rename moves the file on disk with rename() and the path-restriction guard that should keep the operation inside adm_my_files/ is inactive (it is never configured). As a result the file can be relocated to the Admidio web root, outside the adm_my_files/ directory that is protected by .htaccess and whose downloads are deliberately forced to Content-Disposition: attachment. Once an uploaded SVG sits at the web root it is served directly by Apache as image/svg+xml with no attachment disposition and no nosniff, so a browser renders it and executes the script it contains. This yields a stored XSS on the Admidio origin, reachable by any unauthenticated visitor who opens the link, which can be used against a logged-in administrator (session/account takeover).
Details
Affected code
src/Documents/Service/DocumentsService.php—renameFile()github.com/Admidio/ admidio/ blob/ 9c21e94d15ae83818d0a6a33e0caef46763af901/ src/ Documents/ Service/ DocumentsService.php#L393-L427 `` php $formValues = $documentsFilesRenameForm->validate($_POST); // only strips HTML tags ... $newFile = $formValues['adm_new_name'] . '.' . pathinfo($oldFile, PATHINFO_EXTENSION); ... FileSystemUtils::moveFile($oldFile, $newPath . $newFile); // no filename validation`The sibling methodsrenameFolder()(L464) andsaveNewFolder()(L511) **do** callStringUtils::strIsValidFolderName();renameFile()has no equivalentStringUtils::strIsValidFileName()` call — this is the gap.src/Infrastructure/Utils/FileSystemUtils.php—checkIsInAllowedDirectories()github.com/Admidio/ admidio/ blob/ 9c21e94d15ae83818d0a6a33e0caef46763af901/ src/ Infrastructure/ Utils/ FileSystemUtils.php#L287-L302 `` php if (count(self::$allowedDirectories) === 0) { return; // guard disabled when no allowed directories are configured }`FileSystemUtils::setAllowedDirectories()is never called anywhere in the code base, so$allowedDirectories` is always empty and the containment check is a no-op for every file-system operation in the application.
Preconditions
- An authenticated account with upload right in at least one Documents folder. This is a per-folder permission a Documents administrator can grant to any role; it does not require the global administrator role.
- Documents & Files module enabled (enabled by default).
Proof of concept
Verified end to end. The full, from-scratch reproduction (build, run, install, exploit, observed output, cleanup) is in the companion file Admidio__admidio_01_documents-rename-traversal_repro.md.
Observed result (isolated local instance at http://127.0.0.1:18090):
- Upload
poc.svginto the default documents folder → stored atadm_my_files/documents_poc/poc.svg. - Baseline:
GET /adm_my_files/documents_poc/poc.svg→403(htaccess); the official download endpoint serves it asContent-Disposition: attachment+X-Content-Type-Options: nosniff(safe);GET /poc.svg→404. - Rename with
adm_new_name=../../poc→{"status":"success"}; DBfil_namebecomes../../poc.svg; the file is now at the container web root/opt/app-root/src/poc.svg. - GET 127.0.0.1/
poc.svg without any authentication → 200, Content-Type: image/svg+xml, no Content-Disposition, no X-Content-Type-Options, body = the uploaded SVG containing <script>alert('XSS Triggered: ' + document.domain);</script> → executes on the Admidio origin, triggering a popup.
(The script in the PoC triggers a benign alert pop-up to demonstrate execution; no destructive payload or data exfiltration was written, and no live/third-party system was contacted.)
poc.svg:
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<script>alert('XSS Triggered: ' + document.domain);</script>
<text x="5" y="50">codescout poc</text>
</svg>
Impact
- A file can be moved out of the access-controlled,
.htaccess-protectedadm_my_files/tree to a location served directly by the web server (e.g. the Admidio web root). - With an SVG payload this is a stored XSS executing in the Admidio origin, deliverable to any unauthenticated visitor by a plain link (
https://<host>/poc.svg). An administrator opening the link runs attacker JavaScript in their authenticated session (the app uses same-origin requests with a CSRF token readable by same-origin script), enabling account/instance takeover. - Secondary impact: documents can be relocated outside the permission-controlled area.
- Not demonstrated / out of scope: direct code execution. The original file extension is preserved by
renameFile()(the new name isadm_new_name + '.' + <original ext>) and existing files are not overwritten (is_file()check), so a.phpcannot be planted via this path and no RCE was achieved.