{"id":"CVE-2023-40581","aliases":["ALPINE-CVE-2023-40581","EUVD-2023-2412","GHSA-42h4-v29r-42qg","PYSEC-2026-2064"],"status":"published","title":"yt-dlp command injection when using `%q` in `--exec` on Windows","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.","severity":{"version":"3.1","score":8.4,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-10","score":0.0134,"percentile":0.71549,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-78"],"published":"2023-09-25T17:33:40Z","modified":"2026-11-11T10:30:39Z","fixes":[{"ecosystem":"PyPI","package":"yt-dlp","fixed_in":["2023.09.24"],"sources":["ghsa","osv"]},{"ecosystem":"Alpine:v3.19","package":"yt-dlp","fixed_in":["2023.09.24-r0"],"sources":["osv"]},{"ecosystem":"Alpine:v3.20","package":"yt-dlp","fixed_in":["0-r0"],"sources":["osv"]},{"ecosystem":"Alpine:v3.21","package":"yt-dlp","fixed_in":["0-r0"],"sources":["osv"]},{"ecosystem":"Alpine:v3.22","package":"yt-dlp","fixed_in":["0-r0"],"sources":["osv"]},{"ecosystem":"Alpine:v3.23","package":"yt-dlp","fixed_in":["0-r0"],"sources":["osv"]},{"ecosystem":"Alpine:v3.24","package":"yt-dlp","fixed_in":["0-r0"],"sources":["osv"]}],"affected":[{"source":"ghsa","ecosystem":"PyPI","package":"yt-dlp","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2021.04.11"},{"fixed":"2023.09.24"}]}]},{"source":"osv","ecosystem":"Alpine:v3.19","package":"yt-dlp","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2021.04.11"},{"fixed":"2023.09.24-r0"}]}]},{"source":"osv","ecosystem":"Alpine:v3.20","package":"yt-dlp","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2021.04.11"},{"fixed":"0-r0"}]}]},{"source":"osv","ecosystem":"Alpine:v3.21","package":"yt-dlp","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2021.04.11"},{"fixed":"0-r0"}]}]},{"source":"osv","ecosystem":"Alpine:v3.22","package":"yt-dlp","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2021.04.11"},{"fixed":"0-r0"}]}]},{"source":"osv","ecosystem":"Alpine:v3.23","package":"yt-dlp","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2021.04.11"},{"fixed":"0-r0"}]}]},{"source":"osv","ecosystem":"Alpine:v3.24","package":"yt-dlp","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2021.04.11"},{"fixed":"0-r0"}]}]},{"source":"osv","ecosystem":"PyPI","package":"yt-dlp","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2021.04.11"},{"fixed":"2023.09.24"}]}],"versions":["2021.10.10","2021.10.22","2021.10.9","2021.11.10","2021.11.10.1","2021.12.1","2021.12.25","2021.12.27","2021.4.11","2021.4.22","2021.5.11","2021.5.20","2021.6.1","2021.6.23","2021.6.8","2021.6.9","2021.7.21","2021.7.24","2021.7.7","2021.8.10","2021.8.2","2021.9.1","2021.9.2","2021.9.25","2022.1.21","2022.10.4","2022.11.11","2022.2.3","2022.2.4","2022.3.8","2022.3.8.1","2022.3.8.2","2022.4.8","2022.5.18","2022.6.22","2022.6.22.1","2022.6.29","2022.7.17","2022.7.18","2022.8.14","2022.8.19","2022.8.8","2022.9.1","2023.1.2","2023.1.6","2023.2.17","2023.3.3","2023.3.4","2023.6.21","2023.6.22","2023.7.6"]},{"source":"osv","ecosystem":"PyPI","package":"yt-dlp","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"2021.04.11"},{"fixed":"2023.09.24"}]}],"versions":["2021.10.10","2021.10.22","2021.10.9","2021.11.10","2021.11.10.1","2021.12.1","2021.12.25","2021.12.27","2021.4.11","2021.4.22","2021.5.11","2021.5.20","2021.6.1","2021.6.23","2021.6.8","2021.6.9","2021.7.21","2021.7.24","2021.7.7","2021.8.10","2021.8.2","2021.9.1","2021.9.2","2021.9.25","2022.1.21","2022.10.4","2022.11.11","2022.2.3","2022.2.4","2022.3.8","2022.3.8.1","2022.3.8.2","2022.4.8","2022.5.18","2022.6.22","2022.6.22.1","2022.6.29","2022.7.17","2022.7.18","2022.8.14","2022.8.19","2022.8.8","2022.9.1","2023.1.2","2023.1.6","2023.2.17","2023.3.3","2023.3.4","2023.6.21","2023.6.22","2023.7.6"]}],"products":[{"vendor":"yt-dlp","product":"yt-dlp"},{"vendor":"yt-dlp_project","product":"yt-dlp"}],"references":[{"url":"https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg","tags":["x_refsource_CONFIRM","x_transferred","Exploit","Mitigation","Patch","Third Party Advisory","advisory","web"]},{"url":"https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e","tags":["x_refsource_MISC","x_transferred","Patch","fix","web"]},{"url":"https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044","tags":["x_refsource_MISC","x_transferred","Product","Release Notes","web"]},{"url":"https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11","tags":["x_refsource_MISC","x_transferred","Product","Release Notes","web"]},{"url":"https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24","tags":["x_refsource_MISC","x_transferred","Product","Release Notes","web"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-40581","tags":["advisory"]},{"url":"https://github.com/advisories/GHSA-42h4-v29r-42qg","tags":["advisory"]},{"url":"https://security.alpinelinux.org/vuln/CVE-2023-40581","tags":["advisory"]},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/40xxx/CVE-2023-40581.json","tags":["advisory"]},{"url":"https://github.com/yt-dlp/yt-dlp","tags":["package"]},{"url":"https://pypi.org/project/yt-dlp","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2023-40581","title":"yt-dlp command injection when using `%q` in `--exec` on Windows","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.\n","status":"published","published":"2023-09-25T18:54:00.204Z","modified":"2024-09-24T14:48:55.952Z","cvss":[{"version":"3.1","score":8.4,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high","assessor":"cna"}],"cwes":["CWE-78"],"updated_at":"2026-11-02T14:35:21.971258Z"}],"euvd":[{"id":"EUVD-2023-2412","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.\n","status":"published","published":"2023-09-25T18:54:00Z","modified":"2024-09-24T14:48:55Z","cvss":[{"version":"3.1","score":8.4,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high"}],"updated_at":"2026-11-03T00:28:15.73715Z"}],"ghsa":[{"id":"GHSA-42h4-v29r-42qg","title":" yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`","description":"### Impact\n[`yt-dlp`](https://github.com/yt-dlp/yt-dlp) allows the user to provide shell commands to be executed at various stages in its download process through the `--exec` flag. This flag allows output template expansion in its argument, so that video 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.\n\nHowever, the escaping used for `cmd` (the shell used by Python's `subprocess` on Windows) did 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`.\n\nSupport for output template expansion in `--exec`, along with this vulnerable behavior, was added to `yt-dlp` in version [2021.04.11](https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11).\n\n```shell\n\u003e yt-dlp https://youtu.be/Jo66yyCpHcQ --exec \"echo %(title)q\"\n[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ\n[youtube] Jo66yyCpHcQ: Downloading webpage\n[youtube] Jo66yyCpHcQ: Downloading ios player API JSON\n[youtube] Jo66yyCpHcQ: Downloading android player API JSON\n[youtube] Jo66yyCpHcQ: Downloading m3u8 information\n[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251\n[download] Destination: ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of    4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f251.webm\n[download] 100% of    4.80KiB in 00:00:00 at 31.58KiB/s\n[Merger] Merging formats into \"＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)\n[Exec] Executing command: echo \"\\\"\u0026echo(\u0026echo(pwned\u0026rem(\"\n\"\\\"\n\npwned\n```\n\n### Patches\nyt-dlp version 2023.09.24 fixes this issue by properly escaping each special character.\n`\\n` will be replaced by `\\r`, as no way of escaping it has been found.\n\n### Workarounds\nIt 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.\n\nFor Windows users who are not able to upgrade:\n- Avoid using any output template expansion in `--exec` other than `{}` (filepath).\n- If expansion in `--exec` is needed, verify the fields you are using do not contain `\"`, `|` or `\u0026`.\n- Instead of using `--exec`, write the info json and load the fields from it instead.\n\n### References\n- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg\n- https://nvd.nist.gov/vuln/detail/CVE-2023-40581\n- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24\n- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044\n- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e","status":"published","published":"2023-09-25T17:33:40Z","modified":"2023-11-08T05:05:02Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high"}],"cwes":["CWE-78"],"updated_at":"2026-11-02T14:37:16.721714Z"}],"nvd":[{"id":"CVE-2023-40581","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.\n","status":"published","published":"2023-09-25T19:15:09.96Z","modified":"2026-06-17T06:18:33.827Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high","assessor":"secondary"},{"version":"3.1","score":7.8,"vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high","assessor":"primary"}],"cwes":["CWE-78"],"updated_at":"2026-11-02T14:08:31.699785Z"}],"osv":[{"id":"ALPINE-CVE-2023-40581","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.\n","status":"published","published":"2023-09-25T19:15:09.96Z","modified":"2026-11-03T06:32:02.643021524Z","cvss":[{"version":"3.1","score":7.8,"vector":"CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H","level":"high"}],"updated_at":"2026-11-03T07:18:15.355745Z"},{"id":"CVE-2023-40581","title":"yt-dlp command injection when using `%q` in `--exec` on Windows","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.\n","status":"published","published":"2023-09-25T18:54:00.204Z","modified":"2026-11-11T10:30:39.783474095Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high"}],"cwes":["CWE-78"],"updated_at":"2026-11-11T11:06:25.426253Z"},{"id":"GHSA-42h4-v29r-42qg","title":" yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`","description":"### Impact\n[`yt-dlp`](https://github.com/yt-dlp/yt-dlp) allows the user to provide shell commands to be executed at various stages in its download process through the `--exec` flag. This flag allows output template expansion in its argument, so that video 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.\n\nHowever, the escaping used for `cmd` (the shell used by Python's `subprocess` on Windows) did 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`.\n\nSupport for output template expansion in `--exec`, along with this vulnerable behavior, was added to `yt-dlp` in version [2021.04.11](https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11).\n\n```shell\n\u003e yt-dlp https://youtu.be/Jo66yyCpHcQ --exec \"echo %(title)q\"\n[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ\n[youtube] Jo66yyCpHcQ: Downloading webpage\n[youtube] Jo66yyCpHcQ: Downloading ios player API JSON\n[youtube] Jo66yyCpHcQ: Downloading android player API JSON\n[youtube] Jo66yyCpHcQ: Downloading m3u8 information\n[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251\n[download] Destination: ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of    4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f251.webm\n[download] 100% of    4.80KiB in 00:00:00 at 31.58KiB/s\n[Merger] Merging formats into \"＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)\n[Exec] Executing command: echo \"\\\"\u0026echo(\u0026echo(pwned\u0026rem(\"\n\"\\\"\n\npwned\n```\n\n### Patches\nyt-dlp version 2023.09.24 fixes this issue by properly escaping each special character.\n`\\n` will be replaced by `\\r`, as no way of escaping it has been found.\n\n### Workarounds\nIt 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.\n\nFor Windows users who are not able to upgrade:\n- Avoid using any output template expansion in `--exec` other than `{}` (filepath).\n- If expansion in `--exec` is needed, verify the fields you are using do not contain `\"`, `|` or `\u0026`.\n- Instead of using `--exec`, write the info json and load the fields from it instead.\n\n### References\n- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg\n- https://nvd.nist.gov/vuln/detail/CVE-2023-40581\n- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24\n- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044\n- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e","status":"published","published":"2023-09-25T17:33:40Z","modified":"2026-07-07T17:56:20.918147212Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high"}],"cwes":["CWE-78"],"updated_at":"2026-11-02T15:46:36.434231Z"},{"id":"PYSEC-2026-2064","title":" yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`","description":"### Impact\n[`yt-dlp`](https://github.com/yt-dlp/yt-dlp) allows the user to provide shell commands to be executed at various stages in its download process through the `--exec` flag. This flag allows output template expansion in its argument, so that video 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.\n\nHowever, the escaping used for `cmd` (the shell used by Python's `subprocess` on Windows) did 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`.\n\nSupport for output template expansion in `--exec`, along with this vulnerable behavior, was added to `yt-dlp` in version [2021.04.11](https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11).\n\n```shell\n\u003e yt-dlp https://youtu.be/Jo66yyCpHcQ --exec \"echo %(title)q\"\n[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ\n[youtube] Jo66yyCpHcQ: Downloading webpage\n[youtube] Jo66yyCpHcQ: Downloading ios player API JSON\n[youtube] Jo66yyCpHcQ: Downloading android player API JSON\n[youtube] Jo66yyCpHcQ: Downloading m3u8 information\n[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251\n[download] Destination: ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of    4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f251.webm\n[download] 100% of    4.80KiB in 00:00:00 at 31.58KiB/s\n[Merger] Merging formats into \"＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file ＂\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)\n[Exec] Executing command: echo \"\\\"\u0026echo(\u0026echo(pwned\u0026rem(\"\n\"\\\"\n\npwned\n```\n\n### Patches\nyt-dlp version 2023.09.24 fixes this issue by properly escaping each special character.\n`\\n` will be replaced by `\\r`, as no way of escaping it has been found.\n\n### Workarounds\nIt 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.\n\nFor Windows users who are not able to upgrade:\n- Avoid using any output template expansion in `--exec` other than `{}` (filepath).\n- If expansion in `--exec` is needed, verify the fields you are using do not contain `\"`, `|` or `\u0026`.\n- Instead of using `--exec`, write the info json and load the fields from it instead.\n\n### References\n- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg\n- https://nvd.nist.gov/vuln/detail/CVE-2023-40581\n- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24\n- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044\n- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e","status":"published","published":"2026-07-07T11:45:25.140715Z","modified":"2026-07-07T17:47:49.332019688Z","cvss":[{"version":"3.1","score":8.3,"vector":"CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H","level":"high"}],"updated_at":"2026-11-02T15:52:55.537808Z"}]}}
