Medium

NiceGUI: Upload filename sanitization bypass via backslashes allows path traversal on Windows

  • Disclosed: 08.04.2026
  • Updated: 11.10.2026 14:17

Summary

The upload filename sanitization introduced in GHSA-9ffm-fxg3-xrhh uses PurePosixPath(filename).name to strip path components. Since PurePosixPath only recognizes forward slashes (/) as path separators, an attacker can bypass this sanitization on Windows by using backslashes (\) in the upload filename.

Applications that construct file paths using file.name (a pattern demonstrated in NiceGUI's bundled examples) are vulnerable to arbitrary file write on Windows.

Details

The sanitization in nicegui/elements/upload_files.py uses:

python
filename = PurePosixPath(upload.filename or '').name

PurePosixPath treats backslashes as literal characters, not path separators:

python
>>> PurePosixPath('..\\..\\secret\\evil.txt').name
'..\\..\\secret\\evil.txt'  # Not stripped!

When this filename is used in a path operation on Windows (e.g., Path('uploads') / file.name), Windows Path interprets backslashes as directory separators, resolving the path outside the intended directory.

Impact

On Windows deployments of NiceGUI applications that use file.name in path construction:

  • Arbitrary file write outside the intended upload directory
  • Potential remote code execution through overwriting application files or placing executables in known locations
  • Data integrity loss through overwriting existing files

Linux and macOS are not affected, as they treat backslashes as literal filename characters.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
Python (PyPI) nicegui < 3.10.0 3.10.0

References

CVSS score 5.9/10
CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N
Weakness (CWE)
CWE-22
Platform
Python (PyPI)
Package
nicegui
Disclosed
08.04.2026
Updated
11.10.2026 14:17

Sources and licenses

OSV / GitHub Advisory Database - PYSEC-2026-2234 - PyPA Advisory Database; CC BY 4.0

OSV / GitHub Advisory Database - GHSA-w8wv-vfpc-hw2w - CC BY 4.0

Vulnerability history: nicegui

All published vulnerabilities of this package (Python (PyPI)), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (17) in the archive
Total entries
17
First → latest
04.2024 05.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • High 6
  • Medium 11

Disclosures per year

  1. 2024: 1
  2. 2025: 5
  3. 2026: 11
Severity:
  1. NiceGUI: Upload filename sanitization bypass via backslashes allows path traversal on Windows this entry
    Medium · 5.9 CVE-2026-39844 < 3.10.0 3.10.0
  2. High · 7.2 CVE-2026-21873 >= 2.22.0, < 3.5.0 3.5.0
  3. High · 7.5 CVE-2025-21618 < 2.9.1 2.9.1
  4. High · 8.2 CVE-2024-32005 >= 1.4.6, < 1.4.21 1.4.21

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.