Skip to main content
Menu
Advisories

Documents & Files: path traversal in file rename => stored XSS via SVG at web root

GHSA-GP7M-9622-GCW9Published Updated GitHub

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

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.svg into the default documents folder → stored at adm_my_files/documents_poc/poc.svg.
  • Baseline: GET /adm_my_files/documents_poc/poc.svg → 403 (htaccess); the official download endpoint serves it as Content-Disposition: attachment + X-Content-Type-Options: nosniff (safe); GET /poc.svg → 404.
  • Rename with adm_new_name=../../poc → {"status":"success"}; DB fil_name becomes ../../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>

admidio_poc.webm

Impact

  • A file can be moved out of the access-controlled, .htaccess-protected adm_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 is adm_new_name + '.' + <original ext>) and existing files are not overwritten (is_file() check), so a .php cannot be planted via this path and no RCE was achieved.

Affected versions

References

GitHub · Admidio/admidio