GitHub Advisoryadvisory · PyPI

GHSA-9ffm-fxg3-xrhh NiceGUI's Path Traversal via Unsanitized FileUpload.name Enables Arbitrary File Write

HIGH Published 2026-02-05 Modified 2026-06-06 Official page ↗
Aliases
CVE-2026-25732
Ecosystem
PyPI
Packages
nicegui
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N
Weaknesses
CWE-22, CWE-601
Reviewed
2026-02-05

Affected packages

• PyPI nicegui: < 3.7.0 → fixed in 3.7.0

Description

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 and 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 exploit.py 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) ````

Related

Alias · CVE (1)

  • CVE-2026-25732 NiceGUI is a Python-based UI framework. vulnerability

Weakness · CWE (2)

  • CWE-22 Improper Limitation of a Pathname to a Restricted Directory weakness
  • CWE-601 URL Redirection to Untrusted Site weakness

References