{"answers":{"affected":"3 open source packages ship an affected version, including yt-dlp. It affects 1 product.","exploited":"There is no known exploitation of CVE-2023-40581 in the wild and no public exploit code.","fix":"Upgrade yt-dlp to 2023.09.24 or later.","what":"CVE-2023-40581 is a high-severity command injection vulnerability in yt-dlp, published on 25 Sep 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link."},"fix_prompt":"Check this codebase for CVE-2023-40581 and fix it if it is affected.\n\nWhat it is: CVE-2023-40581 is a high-severity command injection vulnerability in yt-dlp, published on 25 Sep 2023. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.\nExploitation: There is no known exploitation of CVE-2023-40581 in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- yt-dlp (PyPI): affected from 2021.04.11; fixed in 2023.09.24\n- yt-dlp (PyPI): affected from 2021.04.11; fixed in 2023.09.24\n- yt-dlp (PyPI): affected from 2021.04.11; fixed in 2023.09.24\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/CVE-2023-40581/ (Markdown: https://insights.sbomify.com/CVE-2023-40581/index.md)","id":"CVE-2023-40581","markdown":"https://insights.sbomify.com/CVE-2023-40581/index.md","name":"CVE-2023-40581","record":{"aliases":["GHSA-42h4-v29r-42qg","PYSEC-2026-2064"],"analysis":{"component_type":"developer_tool","fix_type":"upgrade","impacts":["code_execution"],"network_reachable":"yes","non_default_config":true,"product_category":"yt-dlp media downloader","requires_auth":"none","summary":"Remote code execution via command injection in yt-dlp on Windows when using the --exec flag with malicious metadata.","user_interaction":"required","vuln_class":"command_injection"},"analysis_generated_by":"qwen3.8-flash-next","assigner":"GitHub_M","cpe":[{"product":"yt-dlp","vendor":"yt-dlp_project"}],"cvss":{"score":8.4,"severity":"high","source":"cna","vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","version":"3.1"},"cwes":[{"id":"CWE-78","name":"Improper Neutralization of Special Elements used in an OS Command"}],"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 \u0026. 3. Instead of using --exec, write the info json and load the fields from it instead.","ecosystems":["PyPI"],"exploits":{"exploitdb":0,"first_seen":null,"github_poc":0,"max_poc_stars":null,"metasploit":0,"nuclei":0,"refs":[],"tier":"none_known"},"has_fix":true,"headline":"yt-dlp command injection when using `%q` in `--exec` on Windows","id":"CVE-2023-40581","indexable":true,"kev":null,"kind":"cve","links":{"ecosystem":"PyPI","product":null,"products":[],"type":"command_injection","year":"2023"},"n_packages":3,"n_references":5,"next":{"headline":"Command Injection Vulnerability in find-exec","id":"CVE-2023-40582"},"packages":[{"ecosystem":"PyPI","fixed":["2023.09.24"],"introduced":["2021.04.11"],"last_affected":[],"package":"yt-dlp","purl":null,"source":"GHSA-42h4-v29r-42qg"},{"ecosystem":"PyPI","fixed":["2023.09.24"],"introduced":["2021.04.11"],"last_affected":[],"package":"yt-dlp","purl":"pkg:pypi/yt-dlp","source":"GHSA-42h4-v29r-42qg"},{"ecosystem":"PyPI","fixed":["2023.09.24"],"introduced":["2021.04.11"],"last_affected":[],"package":"yt-dlp","purl":"pkg:pypi/yt-dlp","source":"PYSEC-2026-2064"}],"prev":{"headline":"Freighter mnemonic phrase may be accessed by Javascript through a private API","id":"CVE-2023-40580"},"products":["yt-dlp"],"published":"2023-09-25","related":[{"cvss_score":8.8,"headline":"yt-dlp: Arbitrary Command Injection when using the `--netrc-cmd` option","id":"CVE-2026-26331","kev_date_added":null,"published":"2026-02-24"},{"cvss_score":8.4,"headline":"yt-dlp `--exec` command injection when using `%q` in yt-dlp on Windows","id":"CVE-2024-22423","kev_date_added":null,"published":"2024-04-09"},{"cvss_score":8.3,"headline":"yt-dlp: Dangerous file type creation via insufficient filename sanitization (Bypass of CVE-2024-38519)","id":"CVE-2026-50023","kev_date_added":null,"published":"2026-06-23"},{"cvss_score":8.3,"headline":"yt-dlp: Arbitrary code execution via manifest downloads with aria2c","id":"CVE-2026-50574","kev_date_added":null,"published":"2026-06-23"},{"cvss_score":7.5,"headline":"yt-dlp: Downstream command injection via improper sanitization of yt-dlp --write-link output","id":"CVE-2026-55404","kev_date_added":null,"published":"2026-07-08"},{"cvss_score":7.5,"headline":"yt-dlp allows `--exec` command injection when using placeholder on Windows","id":"CVE-2025-54072","kev_date_added":null,"published":"2025-07-22"}],"sources":[{"class":"attribution","licence":"CVE Terms of Use (MITRE)","name":"CVE List","prefix":"CVE"},{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"},{"class":"attribution","licence":"CC BY 4.0","name":"PyPA Advisory Database","prefix":"PYSEC"},{"class":"attribution","licence":"US public information, NVD API terms","name":"NVD"},{"class":"attribution","licence":"CWE Terms of Use","name":"CWE (MITRE)"},{"class":"attribution","licence":"FIRST CVSS licence","name":"CVSS (FIRST)"}],"ssvc":{"automatable":"no","exploitation":"none","technical_impact":"total"},"state":"PUBLISHED","updated":"2024-09-24","vendors":["yt-dlp"]},"summary":"Remote code execution via command injection in yt-dlp on Windows when using the --exec flag with malicious metadata.","url":"https://insights.sbomify.com/CVE-2023-40581/"}