# CVE-2024-38519: yt-dlp and youtube-dl vulnerable to file system modification and RCE through improper file-extension sanitization

> Attackers can execute arbitrary code or modify files via improper file-extension sanitization in yt-dlp and youtube-dl downloaders.

- **Severity:** High 7.8 (`CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 2 Jul 2024
- **Updated:** 2 Aug 2024
- **Also known as:** DEBIAN-CVE-2024-38519, GHSA-79w7-vh3h-8g4j, PYSEC-2026-2065, UBUNTU-CVE-2024-38519, openSUSE-SU-2024:14094-1

## What is CVE-2024-38519?

CVE-2024-38519 is a high-severity path traversal vulnerability in yt-dlp youtube-dl, published on 2 Jul 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

`yt-dlp` and `youtube-dl` are command-line audio/video downloaders. Prior to the fixed versions, `yt-dlp` and `youtube-dl` do not limit the extensions of downloaded files, which could lead to arbitrary filenames being created in the download folder (and path traversal on Windows). Since `yt-dlp` and `youtube-dl` also read config from the working directory (and on Windows executables will be executed from the `yt-dlp` or `youtube-dl` directory), this could lead to arbitrary code being executed.

`yt-dlp` version 2024.07.01 fixes this issue by whitelisting the allowed extensions. `youtube-dl` fixes this issue in commit `d42a222` on the `master` branch and in nightly builds tagged 2024-07-03 or later. This might mean some very uncommon extensions might not get downloaded, however it will also limit the possible exploitation surface. In addition to upgrading, have `.%(ext)s` at the end of the output template and make sure the user trusts the websites that they are downloading from. Also, make sure to never download to a directory within PATH or other sensitive locations like one's user directory, `system32`, or other binaries locations. For users who are not able to upgrade, keep the default output template (`-o "%(title)s [%(id)s].%(ext)s`); make sure the extension of the media to download is a common video/audio/sub/... one; try to avoid the generic extractor; and/or use `--ignore-config --config-location ...` to not load config from common locations.

Weakness: CWE-669 (Incorrect Resource Transfer Between Spheres)

## Which versions are affected by CVE-2024-38519?

3 open source packages ship an affected version, including yt-dlp.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `yt-dlp` | PyPI | All versions | 2024.07.01 |
| `yt-dlp` | PyPI | All versions | 2024.07.01 |
| `yt-dlp` | PyPI | All versions | 2024.07.01 |
| `yt-dlp` | openSUSE:Tumbleweed | All versions | 2024.07.01-1.1 |

## How do I fix CVE-2024-38519?

Upgrade yt-dlp to 2024.07.01 or later.

## Is CVE-2024-38519 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-38519 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-38519 and fix it if it is affected.

What it is: CVE-2024-38519 is a high-severity path traversal vulnerability in yt-dlp youtube-dl, published on 2 Jul 2024. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-38519 exists.

Affected packages and fixed versions:
- yt-dlp (PyPI): affected all versions; fixed in 2024.07.01
- yt-dlp (PyPI): affected all versions; fixed in 2024.07.01
- yt-dlp (PyPI): affected all versions; fixed in 2024.07.01

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-38519/ (Markdown: https://insights.sbomify.com/CVE-2024-38519/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-38519
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-38519
- OSV: https://osv.dev/vulnerability/CVE-2024-38519

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-38519/
Summaries are generated and may contain mistakes; the official description above is the record.
