GHSA-PQFR-M69J-4MQ2
Incomplete patch of CVE-2025-62382: `image_path` backslash-separator bypass of `pathvalidate.sanitize_filepath` + `startswith(CLIPS_DIR)` reaches `shutil.copy` arbitrary host-file read
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-PQFR-M69J-4MQ2 divulgada · CVSS 7.7 (GitHub) | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Affected
- `blakeblackshear/frigate` `>= v0.16.2` (the original CVE-2025-62382 patch version) through `<= v0.17.1` (latest release as of 2026-06-16) and current `dev`/`master` HEAD (`e84a89e` checked 2026-06-16).
- Validator: `frigate/api/export.py` — `sanitize_filepath(body.image_path)` + `.startswith(CLIPS_DIR)` (lines 94-97 on v0.17.1, refactored into `_sanitize_existing_image()` helper at lines 128-139 on `dev` HEAD and reused across three export endpoints).
- Sink: `frigate/record/export.py:86-93` — `os.path.isfile(self.user_provided_image)` + `shutil.copy(self.user_provided_image, thumb_path)` where `thumb_path = os.path.join(CLIPS_DIR, f"export/{export_id}.webp")`.
- Pinned dependency: `pathvalidate == 3.3.*` in `docker/main/requirements-wheels.txt`.
Summary
The mitigation introduced in commit `4d582062` (PR #20491, shipped in v0.16.2 and re-released as part of v0.17.0/v0.17.1) is the published fix for CVE-2025-62382 / GHSA-8gv4-5jr9-v96j (admin-authenticated arbitrary host-file read via `image_path` on `POST /api/export/...`). The patch normalizes the user-supplied path with `pathvalidate.sanitize_filepath()` and then enforces `existing_image.startswith(CLIPS_DIR)`. It does not collapse `..` segments produced by `pathvalidate`'s backslash-to-forward-slash conversion, so a path that uses `\` as the directory separator survives the validator with `..` segments still present, then resolves against the host filesystem at the `shutil.copy` sink.
On `dev` HEAD the same helper is invoked from three endpoints — `POST /export/{camera_name}/start/{start_time}/end/{end_time}`, `POST /exports/batch`, and the re-export endpoint that reuses an `export_id` — so the bypass is reachable through every export ingress.
Threat model
Identical to the original CVE-2025-62382: admin-authenticated. Original advisory:
> "An authenticated administrator was able to read arbitrary files on the server. This issue was patched in [v0.16.2] and on `dev`."
Frigate's standard deployment runs `--privileged` for GPU access, which amplifies impact: any file readable by the Frigate process (UID 0 in the container) is exfiltrated, including `/etc/shadow`, `/proc/self/environ` (Frigate environment variables: `FRIGATE_RTSP_PASS_*`, `FRIGATE_OPENAI_API_KEY`, and other `FRIGATE_*` MQTT/HTTPS secrets), and any host bind-mounts visible to the container. Same role boundary that the original CVE was filed under (admin → host filesystem) — the patch was meant to seal it, the bypass restores it.
Root cause — validator/consumer normalization disagreement
`frigate/api/export.py` (v0.17.1 lines 94-97):
existing_image = sanitize_filepath(body.image_path) if body.image_path else None
if existing_image and not existing_image.startswith(CLIPS_DIR):
return JSONResponse(
content=({"success": False, "message": "Invalid image path"}),
status_code=400,
)`dev` HEAD (same logic, refactored into a helper at `frigate/api/export.py:128-139` and reused by three callers at lines 655, 800, and 929):
def _sanitize_existing_image(image_path):
existing_image = sanitize_filepath(image_path) if image_path else None
if existing_image and not existing_image.startswith(CLIPS_DIR):
return None, JSONResponse(content={"success": False, "message": "Invalid image path"}, status_code=400)
return existing_image, None`pathvalidate.sanitize_filepath` (v3.3.1 — the latest-pinned version) performs partial normalization: it strips invalid characters per platform and normalizes backslashes (`\`) to forward-slashes (`/`), but it does not recollapse the resulting `..` segments. `str.startswith()` is a literal byte-prefix check and does not canonicalize.
Downstream, `frigate/record/export.py:86-93`:
def save_thumbnail(self, id: str) -> str:
thumb_path = os.path.join(CLIPS_DIR, f"export/{id}.webp")
if self.user_provided_image is not None and os.path.isfile(
self.user_provided_image
):
shutil.copy(self.user_provided_image, thumb_path)
return thumb_path`os.path.isfile()` and `shutil.copy()` (which calls `open()`) are POSIX-canonical: they let the kernel resolve `..` against the existing directory tree. Because `/media/frigate/clips` exists at runtime, `/media/frigate/clips/../../../etc/passwd` resolves to `/etc/passwd` and is copied to `<CLIPS_DIR>/export/<export_id>.webp`.
The disagreement between `pathvalidate.sanitize_filepath` (partial normalization), `str.startswith` (byte-literal), and POSIX kernel path resolution (full `..` collapse) is the bug.
Bypass payload — sanitize table (tested against `pathvalidate == 3.3.1`)
| input | `sanitize_filepath` returns | `.startswith('/media/frigate/clips')` | resolved by `os.path.normpath` |
|-------|-----------------------------|----------------------------------------|---------------------------------|
| `/media/frigate/clips/../../../etc/passwd` | `/etc/passwd` | False — rejected | `/etc/passwd` |
| `/media/frigate/clips\..\..\..\etc/passwd` | `/media/frigate/clips/../../../etc/passwd` | True — passes | `/etc/passwd` |
| `/media/frigate/clips\..\..\etc/passwd` | `/media/frigate/clips/../../etc/passwd` | True — passes | `/media/etc/passwd` |
| `/media/frigate/clips/foo\..\etc/passwd` | `/media/frigate/clips/foo/../etc/passwd` | True — passes | `/media/frigate/clips/etc/passwd` |
The first row is the original CVE-2025-62382 payload that the patch correctly rejects. Every subsequent row is a `\`-separator variant that the patch lets through with `..` segments intact.
Reach chain (request → file read)
- Authenticated admin sends:
```http
POST /api/export/<camera>/start/<start_ts>/end/<end_ts> HTTP/1.1
Content-Type: application/json
{"playback":"realtime","source":"recordings","image_path":"/media/frigate/clips\\..\\..\\..\\etc/passwd"}
```
- `export_recording` calls `sanitize_filepath('/media/frigate/clips\\..\\..\\..\\etc/passwd')` → `/media/frigate/clips/../../../etc/passwd`. `existing_image.startswith('/media/frigate/clips')` → True. Validator passes.
- `RecordingExporter` is constructed with `image='/media/frigate/clips/../../../etc/passwd'`, `exporter.start()` triggers `save_thumbnail(export_id)`.
- `os.path.isfile('/media/frigate/clips/../../../etc/passwd')` → kernel resolves `..` → `/etc/passwd` exists → True.
- `shutil.copy('/media/frigate/clips/../../../etc/passwd', '/media/frigate/clips/export/<export_id>.webp')` opens `/etc/passwd`, copies its bytes to the export thumbnail path.
- API response returns `{"success": true, "export_id": "<camera>_<6 lowercase alnum>"}`. The admin downloads the file via nginx static-served `/clips/export/<export_id>.webp` (location `/clips/` in `docker/main/rootfs/usr/local/nginx/conf/nginx.conf:148-162`). The `.webp` extension is cosmetic — content-type sniffing does not block read.
Static replay (no live target required)
Exercising `pathvalidate.sanitize_filepath(...).startswith('/media/frigate/clips')` against the four configurations above empirically confirms three bypasses against the patched validator, on the exact `pathvalidate == 3.3.1` version pinned in `docker/main/requirements-wheels.txt` on v0.17.1.
Recommended remediation
Replace the partial-sanitize + `startswith` pattern with a canonical-path comparison:
from pathlib import Path
def _sanitize_existing_image(image_path):
if not image_path:
return None, None
try:
resolved = Path(image_path).resolve(strict=True)
except (OSError, RuntimeError):
return None, JSONResponse(
content={"success": False, "message": "Invalid image path"}, status_code=400,
)
clips_root = Path(CLIPS_DIR).resolve()
if not resolved.is_relative_to(clips_root):
return None, JSONResponse(
content={"success": False, "message": "Invalid image path"}, status_code=400,
)
return str(resolved), None`Path.resolve(strict=True)` canonicalizes (including `..` collapse) and raises if the path doesn't exist. `Path.is_relative_to(...)` (Python 3.9+) performs a logical (not byte-literal) prefix check on canonicalized paths. An equivalent fix that avoids `strict=True` is `os.path.realpath` on both sides, comparing with a trailing-`os.sep` guard to prevent `/media/frigate/clips_backdoor` from sneaking under a `startswith` check.
References
- Original advisory: https://github.com/blakeblackshear/frigate/security/advisories/GHSA-8gv4-5jr9-v96j
- CVE-2025-62382
- Mitigation PR: https://github.com/blakeblackshear/frigate/pull/20491
- Mitigation commit: `4d582062fba09f69fb40658fbe02b4f527dc46af`
- `pathvalidate` upstream: https://pypi.org/project/pathvalidate/ (pinned `3.3.*` in `docker/main/requirements-wheels.txt`)
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
pypifrigate |
Sin parche | — | — | 0.7.0 no afectada |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/blakeblackshear/frigate/security/advisories/GHSA-pqfr-m69j-4mq2Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
