{"schemaVersion":3,"id":"CVE-2023-40581","aliases":["GHSA-42h4-v29r-42qg","PYSEC-2026-2064"],"status":"published","duplicateOf":null,"title":null,"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.","dates":{"published":"2023-09-25T18:54:00.204Z","modified":"2024-09-24T14:48:55.952Z","reserved":null,"kevAdded":[],"kevDue":[]},"cvss":{"headline":{"score":8.4,"severity":"high","version":"3.1","versionLabel":"v3.1","source":"CVE.org","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","computed":false,"selection":"backend-summary"},"metrics":[{"version":"3.1","versionLabel":"v3.1","source":"CVE.org","score":8.4,"severity":"high","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","exploitability":null,"impact":null,"computed":false},{"version":"3.1","versionLabel":"v3.1","source":"OSV · Pypi","score":8.3,"severity":"high","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","exploitability":4.1,"impact":10,"computed":true},{"version":"3.1","versionLabel":"v3.1","source":"NVD","score":7.8,"severity":"high","vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","exploitability":null,"impact":null,"computed":false}]},"epss":{"probability":0.0134,"percentile":0.71047,"severity":"low","asOf":"2026-10-21T00:00:00.000Z","change":{"pp":0.048000000000000126,"baselineDate":"2026-09-21T00:00:00.000Z","baselineScore":0.01292},"history":[{"date":"2026-09-14T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-15T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-16T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-17T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-18T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-19T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-20T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-21T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-22T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-23T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-24T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-25T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-26T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-27T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-28T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-29T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-30T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-01T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-02T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-03T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-04T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-05T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-06T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-07T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-08T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-09T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-10T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-11T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-12T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-13T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-14T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-15T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-16T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-17T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-18T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-19T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-20T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-21T00:00:00.000Z","score":0.0134,"percentile":0.71047}],"last30":[{"date":"2026-09-21T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-22T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-23T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-24T00:00:00.000Z","score":0.01292,"percentile":null},{"date":"2026-09-25T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-26T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-27T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-28T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-29T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-09-30T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-01T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-02T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-03T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-04T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-05T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-06T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-07T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-08T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-09T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-10T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-11T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-12T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-13T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-14T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-15T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-16T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-17T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-18T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-19T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-20T00:00:00.000Z","score":0.0134,"percentile":null},{"date":"2026-10-21T00:00:00.000Z","score":0.0134,"percentile":0.71047}]},"kev":{"state":"not-listed","entries":[],"listedCount":0,"totalCatalogs":3,"catalogs":[{"source":"cisa","label":"CISA","listed":false,"entry":null},{"source":"enisa","label":"ENISA","listed":false,"entry":null},{"source":"circl","label":"CIRCL","listed":false,"entry":null}]},"ransomware":{"state":"none-recorded","sources":[]},"exploits":[{"id":"GITHUB_YT-DLP_YT-DLP","name":"Yt Dlp","source":"github","url":"https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg","maturity":"poc","reliabilityScore":0.3,"verified":false,"type":null,"platforms":[],"requiresAuth":null,"exploitdb":null,"metasploit":null}],"exploitCount":1,"weaknesses":[{"id":"CWE-78","name":"Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')","description":"The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.","type":"weakness","status":"Stable","abstraction":"Base","likelihoodOfExploit":"High","url":"https://cwe.mitre.org/data/definitions/78.html"}],"affected":[{"vendor":"PyPI","product":"yt-dlp","name":"yt-dlp","label":"yt-dlp","ecosystem":"PyPI","cpePart":null,"purl":"pkg:pypi/yt-dlp","purlType":"pypi","versions":[{"text":"≥ 2021.04.11, < 2023.09.24","noFixRecorded":false,"fixedIn":null}],"versionsText":"≥ 2021.04.11, < 2023.09.24","eol":null,"hubHref":null},{"vendor":"yt-dlp_project","product":"yt-dlp","name":"yt-dlp","label":"yt-dlp","ecosystem":null,"cpePart":"a","purl":null,"purlType":null,"versions":[{"text":"≥ 2021.04.11, < 2023.09.24","noFixRecorded":false,"fixedIn":null}],"versionsText":"≥ 2021.04.11, < 2023.09.24","eol":null,"hubHref":"/vendor/yt-dlp_project/yt-dlp"},{"vendor":"yt-dlp","product":"yt-dlp","name":"yt-dlp","label":"yt-dlp","ecosystem":null,"cpePart":"a","purl":null,"purlType":null,"versions":[{"text":"≥ 2021.04.11, < 2023.09.24","noFixRecorded":false,"fixedIn":null},{"text":"< nightly 2023.09.24.003044","noFixRecorded":false,"fixedIn":null}],"versionsText":"≥ 2021.04.11, < 2023.09.24 | < nightly 2023.09.24.003044","eol":null,"hubHref":"/vendor/yt-dlp/yt-dlp"}],"affectedCount":3,"eol":{"hasEol":false,"count":0},"references":[{"url":"https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg","label":"github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg","hostname":"github.com","tags":["X Refsource CONFIRM","WEB","Exploit","Mitigation","Patch","Third Party Advisory"]},{"url":"https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e","label":"github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e","hostname":"github.com","tags":["X Refsource MISC","WEB","Patch"]},{"url":"https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044","label":"github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044","hostname":"github.com","tags":["X Refsource MISC","WEB","Product","Release Notes"]},{"url":"https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11","label":"github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11","hostname":"github.com","tags":["X Refsource MISC","WEB","Product","Release Notes"]},{"url":"https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24","label":"github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24","hostname":"github.com","tags":["X Refsource MISC","WEB","Product","Release Notes"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-40581","label":"nvd.nist.gov/vuln/detail/CVE-2023-40581","hostname":"nvd.nist.gov","tags":["Advisory"]},{"url":"https://github.com/yt-dlp/yt-dlp","label":"github.com/yt-dlp/yt-dlp","hostname":"github.com","tags":["PACKAGE"]},{"url":"https://pypi.org/project/yt-dlp","label":"pypi.org/project/yt-dlp","hostname":"pypi.org","tags":["PACKAGE"]},{"url":"https://github.com/advisories/GHSA-42h4-v29r-42qg","label":"github.com/advisories/GHSA-42h4-v29r-42qg","hostname":"github.com","tags":["Advisory"]}],"lineage":{"upstream":[],"downstream":[],"duplicates":[],"related":["CVE-2024-22423"]},"timeline":[{"kind":"published","date":"2023-09-25T18:54:00.204Z","label":"Published","detail":"Vulnerability first disclosed.","source":null},{"kind":"modified","date":"2024-09-24T14:48:55.952Z","label":"Last modified","detail":"Vulnerability information updated.","source":null}],"risk":{"score":44,"level":"medium","profile":"Default","thresholds":{"critical":75,"high":50,"medium":25,"low":10}},"meta":{"dataAsOf":"2026-10-22T05:52:17.746Z","stale":false,"partial":false}}