8.3
HIGH
CVE-2023-40581
YouTube Downloader (yt-dlp) Remote Code Execution Vulnerability
Description

yt-dlp is a youtube-dl fork with additional features and fixes. yt-dlp allows the user to provide shell command lines to be executed at various stages in its download steps through the `--exec` flag. This flag allows output template expansion in its argument, so that metadata values may be used in the shell commands. The metadata fields can be combined with the `%q` conversion, which is intended to quote/escape these values so they can be safely passed to the shell. However, the escaping used for `cmd` (the shell used by Python's `subprocess` on Windows) does not properly escape special characters, which can allow for remote code execution if `--exec` is used directly with maliciously crafted remote data. This vulnerability only impacts `yt-dlp` on Windows, and the vulnerability is present regardless of whether `yt-dlp` is run from `cmd` or from `PowerShell`. Support for output template expansion in `--exec`, along with this vulnerable behavior, was added to `yt-dlp` in version 2021.04.11. yt-dlp version 2023.09.24 fixes this issue by properly escaping each special character. `\n` will be replaced by `\r` as no way of escaping it has been found. It is recommended to upgrade yt-dlp to version 2023.09.24 as soon as possible. Also, always be careful when using --exec, because while this specific vulnerability has been patched, using unvalidated input in shell commands is inherently dangerous. For Windows users who are not able to upgrade: 1. Avoid using any output template expansion in --exec other than {} (filepath). 2. If expansion in --exec is needed, verify the fields you are using do not contain ", | or &. 3. Instead of using --exec, write the info json and load the fields from it instead.

INFO

Published Date :

Sept. 25, 2023, 7:15 p.m.

Last Modified :

Sept. 27, 2023, 2:48 p.m.

Remotely Exploitable :

Yes !

Impact Score :

6.0

Exploitability Score :

1.6
Affected Products

The following products are affected by CVE-2023-40581 vulnerability. Even if cvefeed.io is aware of the exact versions of the products that are affected, the information is not represented in the table below.

ID Vendor Product Action
1 Yt-dlp_project yt-dlp
References to Advisories, Solutions, and Tools

Here, you will find a curated list of external links that provide in-depth information, practical solutions, and valuable tools related to CVE-2023-40581.

URL Resource
https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044 Product Release Notes
https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e Patch
https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11 Product Release Notes
https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24 Product Release Notes
https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg Exploit Mitigation Patch Third Party Advisory

We scan GitHub repositories to detect new proof-of-concept exploits. Following list is a collection of public exploits and proof-of-concepts, which have been published on GitHub (sorted by the most recently updated).

Results are limited to the first 15 repositories due to potential performance issues.

The following list is the news that have been mention CVE-2023-40581 vulnerability anywhere in the article.

The following table lists the changes that have been made to the CVE-2023-40581 vulnerability over time.

Vulnerability history details can be useful for understanding the evolution of a vulnerability, and for identifying the most recent changes that may impact the vulnerability's severity, exploitability, or other characteristics.

  • CVE Modified by [email protected]

    May. 14, 2024

    Action Type Old Value New Value
  • Initial Analysis by [email protected]

    Sep. 27, 2023

    Action Type Old Value New Value
    Added CVSS V3.1 NIST AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
    Changed Reference Type https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e No Types Assigned https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e Patch
    Changed Reference Type https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11 No Types Assigned https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11 Product, Release Notes
    Changed Reference Type https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24 No Types Assigned https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24 Product, Release Notes
    Changed Reference Type https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg No Types Assigned https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg Exploit, Mitigation, Patch, Third Party Advisory
    Changed Reference Type https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044 No Types Assigned https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044 Product, Release Notes
    Added CPE Configuration AND OR *cpe:2.3:a:yt-dlp_project:yt-dlp:*:*:*:*:*:*:*:* versions from (including) 2021.04.11 up to (excluding) 2023.09.24 OR cpe:2.3:o:microsoft:windows:-:*:*:*:*:*:*:*
EPSS is a daily estimate of the probability of exploitation activity being observed over the next 30 days. Following chart shows the EPSS score history of the vulnerability.
CWE - Common Weakness Enumeration

While CVE identifies specific instances of vulnerabilities, CWE categorizes the common flaws or weaknesses that can lead to vulnerabilities. CVE-2023-40581 is associated with the following CWEs:

Common Attack Pattern Enumeration and Classification (CAPEC)

Exploit Prediction

EPSS is a daily estimate of the probability of exploitation activity being observed over the next 30 days.

0.75 }} 0.22%

score

0.81253

percentile

CVSS31 - Vulnerability Scoring System
Attack Vector
Attack Complexity
Privileges Required
User Interaction
Scope
Confidentiality
Integrity
Availability