Skip to content

youtube-dl vulnerable to file system modification and RCE through improper file-extension sanitization

High severity GitHub Reviewed Published Jul 2, 2024 in dirkf/youtube-dl • Updated Apr 18, 2025

Package

pip youtube-dl (pip)

Affected versions

>= 2015.01.25, <= 2021.12.17

Patched versions

2024-07-03

Description

Description

This advisory follows the security advisory GHSA-79w7-vh3h-8g4j published by the yt-dlp/yt-dlp project to aid remediation of the issue in the ytdl-org/youtube-dl project.

Vulnerability

youtube-dl does not limit the extensions of downloaded files, which could lead to arbitrary filenames being created in the download folder (and path traversal on Windows).

Impact

Since youtube-dl also reads config from the working directory (and, on Windows, executables will be executed from the youtube-dl directory by default) the vulnerability could allow the unwanted execution of local code, including downloads masquerading as, eg, subtitles.

Patches

The versions of youtube-dl listed as Patched remediate this vulnerability by disallowing path separators and whitelisting allowed extensions. As a result, some very uncommon extensions might not get downloaded.

Workarounds

Any/all of the below considerations may limit exposure in case it is necessary to use a vulnerable version

  • have .%(ext)s at the end of the output template
  • download from websites that you trust
  • do not download to a directory within the executable search PATH or other sensitive locations, such as your user directory or system directories
  • in Windows versions that support it, set NoDefaultCurrentDirectoryInExePath to prevent the cmd shell's executable search adding the default directory before PATH
  • consider that the path traversal vulnerability as a result of resolving non_existent_dir\..\..\target does not exist in Linux or macOS
  • ensure the extension of the media to download is a common video/audio/... one (use --get-filename)
  • omit any of the subtitle options (--write-subs/ --write-srt, --write-auto-subs/--write-automatic-subs, --all-subs).

References

References

@dirkf dirkf published to dirkf/youtube-dl Jul 2, 2024
Published to the GitHub Advisory Database Apr 18, 2025
Reviewed Apr 18, 2025
Last updated Apr 18, 2025

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
Low
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

EPSS score

CVE ID

No known CVE

GHSA ID

GHSA-22fp-mf44-f2mq

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.