Skip to content

File Downloader cookie leak in youtube-dl

Moderate
dirkf published GHSA-9jqj-9wwh-r5mg Jul 18, 2023

Package

pip youtube-dl (pip)

Affected versions

2015.01.25 - 2021.12.17 and daily/nightly builds up to publication of this advisory

Patched versions

Master code 47214e4 and later; daily/nightly builds tagged 2023-07-18 or later

Description

This advisory follows the security advisory GHSA-v8mc-9377-rwjj published by the yt-dlp/yt-dlp project to aid remediation of the issue in the ytdl-org/youtube-dl project.

Vulnerability

During file downloads, youtube-dl or the external downloaders that it invokes may leak cookies on HTTP redirects to a different host, or leak them when the host for download fragments differs from their parent manifest's host.

This vulnerable behaviour is present in all versions of youtube-dl and forks released since 2015-01-25. All native and external downloaders are affected, except for curl and httpie (for version 3.1.0 or later).

At the file download stage, all cookies are passed by youtube-dl to the file downloader as a Cookie header, thereby losing their scope. This also occurs in the .info.json output, which may be used by external tools. As a result, the downloader or external tool may indiscriminately send cookies with requests to domains or paths for which the cookies are not scoped.

Impact

In a worst case scenario, this vulnerability could allow a threat actor to exfiltrate a user's account cookies for a site. For example, a malicious actor could use a URL redirect vulnerability in the target site for which the user has account cookies to redirect to the actor's server. A maliciously crafted website could cause youtube-dl to use this URL as a download format and leak the user's account cookies to the malicious actor.

Patches

The master code of youtube-dl as of 2023-07-18 remediates this vulnerability by:

  • removing the Cookie header on HTTP redirects
  • having native downloaders calculate their own Cookie header from the Cookiejar
  • using each external downloader's built-in support for cookies, instead of passing them as header arguments; or if the external downloader does not have proper cookie support, disabling HTTP redirection (axel only)
  • processing cookies passed as HTTP headers to limit their scope (--add-header "Cookie:..." is scoped to the input URL domain only)
  • storing cookies in a separate cookies field of the info dict instead of http_headers so as not to lose their scope.

These changes are incorporated in nightly builds dated 2023-07-18 or later.

Workarounds

For users who are not able to upgrade youtube-dl from master code or install a nightly release:

  • avoid using cookies and user authentication methods (--cookies, --password/-p, --netrc); while extractors may set custom cookies, these usually do not contain sensitive information.
  • avoid using --load-info-json.

If authentication is a must:

  • verify integrity of download links from unknown sources in the browser (including redirects) before passing them to youtube-dl
  • use curl as an external downloader, as it is not affected (--downloader curl)
  • avoid fragmented formats such as HLS/m3u8, DASH/mpd and ISM (use -f "(bestvideo+bestaudio/best)[protocol^=http]").

References

Severity

Moderate

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
Network
Attack complexity
High
Privileges required
None
User interaction
Required
Scope
Changed
Confidentiality
High
Integrity
None
Availability
None

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:N/AC:H/PR:N/UI:R/S:C/C:H/I:N/A:N

CVE ID

CVE-2023-35934

Weaknesses

No CWEs

Credits