# GHSA-GP7M-9622-GCW9: Documents & Files: path traversal in file rename =\> stored XSS via SVG at web root

- Database: GitHub
- Severity: CVSS 8.7 (High)
- Published: 2026-11-06
- Modified: 2026-11-06

## Affected versions

- admidio (Packagist): through 5.0.17

## Description

### Summary

- **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()`
  https://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 methods `renameFolder()` (L464) and `saveNewFolder()` (L511) **do** call
  `StringUtils::strIsValidFolderName()`; `renameFile()` has no equivalent
  `StringUtils::strIsValidFileName()` call — this is the gap.
- `src/Infrastructure/Utils/FileSystemUtils.php` — `checkIsInAllowedDirectories()`
  https://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.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 http://127.0.0.1:18090/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](https://github.com/user-attachments/assets/4a291baf-5f96-4717-95b7-97edde22b6df)



### 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.

## References

- https://github.com/Admidio/admidio/security/advisories/GHSA-gp7m-9622-gcw9

Page: https://cve.now/GHSA-GP7M-9622-GCW9

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
