Action not permitted
Modal body text goes here.
Modal Title
Modal Body
PYSEC-2026-2064
Vulnerability from pysec - Published: 2026-07-07 11:45 - Updated: 2026-07-07 17:25Impact
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.
However, 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.
Support for output template expansion in --exec, along with this vulnerable behavior, was added to yt-dlp in version 2021.04.11.
> yt-dlp https://youtu.be/Jo66yyCpHcQ --exec "echo %(title)q"
[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ
[youtube] Jo66yyCpHcQ: Downloading webpage
[youtube] Jo66yyCpHcQ: Downloading ios player API JSON
[youtube] Jo66yyCpHcQ: Downloading android player API JSON
[youtube] Jo66yyCpHcQ: Downloading m3u8 information
[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4
[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm
[download] 100% of 4.80KiB in 00:00:00 at 31.58KiB/s
[Merger] Merging formats into ""&echo(&echo(pwned&rem( [Jo66yyCpHcQ].mkv"
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)
[Exec] Executing command: echo "\"&echo(&echo(pwned&rem("
"\"
pwned
Patches
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.
Workarounds
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:
- Avoid using any output template expansion in --exec other than {} (filepath).
- If expansion in --exec is needed, verify the fields you are using do not contain ", | or &.
- Instead of using --exec, write the info json and load the fields from it instead.
References
- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg
- https://nvd.nist.gov/vuln/detail/CVE-2023-40581
- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24
- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044
- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e
| Name | purl | yt-dlp | pkg:pypi/yt-dlp |
|---|
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "yt-dlp",
"purl": "pkg:pypi/yt-dlp"
},
"ranges": [
{
"events": [
{
"introduced": "2021.04.11"
},
{
"fixed": "2023.09.24"
}
],
"type": "ECOSYSTEM"
}
],
"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"
]
}
],
"aliases": [
"CVE-2023-40581",
"GHSA-42h4-v29r-42qg"
],
"details": "### 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\u0027s `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: \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: \uff02\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 \"\uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file \uff02\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",
"id": "PYSEC-2026-2064",
"modified": "2026-07-07T17:25:52.678461Z",
"published": "2026-07-07T11:45:25.140715Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-40581"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
},
{
"type": "PACKAGE",
"url": "https://github.com/yt-dlp/yt-dlp"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
},
{
"type": "PACKAGE",
"url": "https://pypi.org/project/yt-dlp"
},
{
"type": "ADVISORY",
"url": "https://github.com/advisories/GHSA-42h4-v29r-42qg"
}
],
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": " yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`"
}
BREW-GAMDL-CVE-2023-40581 (GHSA-42H4-V29R-42QG)
Vulnerability from osv_homebrew – Published: 2026-08-13 16:49 – Updated: 2026-09-09 23:59 – Source websiteImpact
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.
However, 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.
Support for output template expansion in --exec, along with this vulnerable behavior, was added to yt-dlp in version 2021.04.11.
> yt-dlp https://youtu.be/Jo66yyCpHcQ --exec "echo %(title)q"
[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ
[youtube] Jo66yyCpHcQ: Downloading webpage
[youtube] Jo66yyCpHcQ: Downloading ios player API JSON
[youtube] Jo66yyCpHcQ: Downloading android player API JSON
[youtube] Jo66yyCpHcQ: Downloading m3u8 information
[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4
[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm
[download] 100% of 4.80KiB in 00:00:00 at 31.58KiB/s
[Merger] Merging formats into ""&echo(&echo(pwned&rem( [Jo66yyCpHcQ].mkv"
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)
[Exec] Executing command: echo "\"&echo(&echo(pwned&rem("
"\"
pwned
Patches
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.
Workarounds
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:
- Avoid using any output template expansion in --exec other than {} (filepath).
- If expansion in --exec is needed, verify the fields you are using do not contain ", | or &.
- Instead of using --exec, write the info json and load the fields from it instead.
References
- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg
- https://nvd.nist.gov/vuln/detail/CVE-2023-40581
- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24
- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044
- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "yt-dlp",
"resource_purl": "pkg:pypi/yt-dlp@2026.7.4",
"upstream_fixed_in": "2023.09.24"
},
"package": {
"ecosystem": "Homebrew",
"name": "gamdl",
"purl": "pkg:brew/gamdl"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.8.5"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/yt-dlp@2026.7.4",
"name": "yt-dlp",
"resource": "yt-dlp",
"strategy": "registry",
"subject_version": "2026.7.4"
}
]
},
"details": "### 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\u0027s `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: \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: \uff02\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 \"\uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file \uff02\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",
"id": "BREW-gamdl-CVE-2023-40581",
"modified": "2026-09-09T23:59:22Z",
"published": "2026-08-13T16:49:04Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-40581"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
},
{
"type": "PACKAGE",
"url": "https://github.com/yt-dlp/yt-dlp"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": " yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`",
"upstream": [
"GHSA-42h4-v29r-42qg",
"CVE-2023-40581",
"PYSEC-2026-2064"
]
}
BREW-MOODLE-DL-CVE-2023-40581 (GHSA-42H4-V29R-42QG)
Vulnerability from osv_homebrew – Published: 2026-08-13 17:14 – Updated: 2026-09-10 00:32 – Source websiteImpact
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.
However, 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.
Support for output template expansion in --exec, along with this vulnerable behavior, was added to yt-dlp in version 2021.04.11.
> yt-dlp https://youtu.be/Jo66yyCpHcQ --exec "echo %(title)q"
[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ
[youtube] Jo66yyCpHcQ: Downloading webpage
[youtube] Jo66yyCpHcQ: Downloading ios player API JSON
[youtube] Jo66yyCpHcQ: Downloading android player API JSON
[youtube] Jo66yyCpHcQ: Downloading m3u8 information
[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4
[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm
[download] 100% of 4.80KiB in 00:00:00 at 31.58KiB/s
[Merger] Merging formats into ""&echo(&echo(pwned&rem( [Jo66yyCpHcQ].mkv"
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)
[Exec] Executing command: echo "\"&echo(&echo(pwned&rem("
"\"
pwned
Patches
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.
Workarounds
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:
- Avoid using any output template expansion in --exec other than {} (filepath).
- If expansion in --exec is needed, verify the fields you are using do not contain ", | or &.
- Instead of using --exec, write the info json and load the fields from it instead.
References
- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg
- https://nvd.nist.gov/vuln/detail/CVE-2023-40581
- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24
- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044
- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e
| URL | Type | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "yt-dlp",
"resource_purl": "pkg:pypi/yt-dlp@2026.7.4",
"upstream_fixed_in": "2023.09.24"
},
"package": {
"ecosystem": "Homebrew",
"name": "moodle-dl",
"purl": "pkg:brew/moodle-dl"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.3.13_12"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/yt-dlp@2026.7.4",
"name": "yt-dlp",
"resource": "yt-dlp",
"strategy": "registry",
"subject_version": "2026.7.4"
}
]
},
"details": "### 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\u0027s `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: \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: \uff02\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 \"\uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file \uff02\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",
"id": "BREW-moodle-dl-CVE-2023-40581",
"modified": "2026-09-10T00:32:32Z",
"published": "2026-08-13T17:14:32Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-40581"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
},
{
"type": "PACKAGE",
"url": "https://github.com/yt-dlp/yt-dlp"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": " yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`",
"upstream": [
"GHSA-42h4-v29r-42qg",
"CVE-2023-40581",
"PYSEC-2026-2064"
]
}
BREW-SCDL-CVE-2023-40581 (GHSA-42H4-V29R-42QG)
Vulnerability from osv_homebrew – Published: 2026-08-13 17:34 – Updated: 2026-09-10 01:11 – Source websiteImpact
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.
However, 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.
Support for output template expansion in --exec, along with this vulnerable behavior, was added to yt-dlp in version 2021.04.11.
> yt-dlp https://youtu.be/Jo66yyCpHcQ --exec "echo %(title)q"
[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ
[youtube] Jo66yyCpHcQ: Downloading webpage
[youtube] Jo66yyCpHcQ: Downloading ios player API JSON
[youtube] Jo66yyCpHcQ: Downloading android player API JSON
[youtube] Jo66yyCpHcQ: Downloading m3u8 information
[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4
[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm
[download] 100% of 4.80KiB in 00:00:00 at 31.58KiB/s
[Merger] Merging formats into ""&echo(&echo(pwned&rem( [Jo66yyCpHcQ].mkv"
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)
[Exec] Executing command: echo "\"&echo(&echo(pwned&rem("
"\"
pwned
Patches
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.
Workarounds
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:
- Avoid using any output template expansion in --exec other than {} (filepath).
- If expansion in --exec is needed, verify the fields you are using do not contain ", | or &.
- Instead of using --exec, write the info json and load the fields from it instead.
References
- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg
- https://nvd.nist.gov/vuln/detail/CVE-2023-40581
- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24
- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044
- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e
| URL | Type | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "yt-dlp",
"resource_purl": "pkg:pypi/yt-dlp@2026.8.19",
"upstream_fixed_in": "2023.09.24"
},
"package": {
"ecosystem": "Homebrew",
"name": "scdl",
"purl": "pkg:brew/scdl"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.0.7"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/yt-dlp@2026.8.19",
"name": "yt-dlp",
"resource": "yt-dlp",
"strategy": "registry",
"subject_version": "2026.8.19"
}
]
},
"details": "### 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\u0027s `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: \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: \uff02\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 \"\uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file \uff02\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",
"id": "BREW-scdl-CVE-2023-40581",
"modified": "2026-09-10T01:11:31Z",
"published": "2026-08-13T17:34:18Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-40581"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
},
{
"type": "PACKAGE",
"url": "https://github.com/yt-dlp/yt-dlp"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": " yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`",
"upstream": [
"GHSA-42h4-v29r-42qg",
"CVE-2023-40581",
"PYSEC-2026-2064"
]
}
BREW-TUBEUP-CVE-2023-40581 (GHSA-42H4-V29R-42QG)
Vulnerability from osv_homebrew – Published: 2026-08-13 17:44 – Updated: 2026-09-10 01:31 – Source websiteImpact
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.
However, 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.
Support for output template expansion in --exec, along with this vulnerable behavior, was added to yt-dlp in version 2021.04.11.
> yt-dlp https://youtu.be/Jo66yyCpHcQ --exec "echo %(title)q"
[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ
[youtube] Jo66yyCpHcQ: Downloading webpage
[youtube] Jo66yyCpHcQ: Downloading ios player API JSON
[youtube] Jo66yyCpHcQ: Downloading android player API JSON
[youtube] Jo66yyCpHcQ: Downloading m3u8 information
[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4
[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm
[download] 100% of 4.80KiB in 00:00:00 at 31.58KiB/s
[Merger] Merging formats into ""&echo(&echo(pwned&rem( [Jo66yyCpHcQ].mkv"
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)
[Exec] Executing command: echo "\"&echo(&echo(pwned&rem("
"\"
pwned
Patches
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.
Workarounds
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:
- Avoid using any output template expansion in --exec other than {} (filepath).
- If expansion in --exec is needed, verify the fields you are using do not contain ", | or &.
- Instead of using --exec, write the info json and load the fields from it instead.
References
- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg
- https://nvd.nist.gov/vuln/detail/CVE-2023-40581
- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24
- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044
- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e
| URL | Type | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "yt-dlp",
"resource_purl": "pkg:pypi/yt-dlp@2026.7.4",
"upstream_fixed_in": "2023.09.24"
},
"package": {
"ecosystem": "Homebrew",
"name": "tubeup",
"purl": "pkg:brew/tubeup"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2026.5.8_1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/yt-dlp@2026.7.4",
"name": "yt-dlp",
"resource": "yt-dlp",
"strategy": "registry",
"subject_version": "2026.7.4"
}
]
},
"details": "### 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\u0027s `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: \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: \uff02\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 \"\uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file \uff02\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",
"id": "BREW-tubeup-CVE-2023-40581",
"modified": "2026-09-10T01:31:23Z",
"published": "2026-08-13T17:44:53Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-40581"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
},
{
"type": "PACKAGE",
"url": "https://github.com/yt-dlp/yt-dlp"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": " yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`",
"upstream": [
"GHSA-42h4-v29r-42qg",
"CVE-2023-40581",
"PYSEC-2026-2064"
]
}
BREW-YEWTUBE-CVE-2023-40581 (GHSA-42H4-V29R-42QG)
Vulnerability from osv_homebrew – Published: 2026-08-13 17:55 – Updated: 2026-09-10 21:31 – Source websiteImpact
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.
However, 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.
Support for output template expansion in --exec, along with this vulnerable behavior, was added to yt-dlp in version 2021.04.11.
> yt-dlp https://youtu.be/Jo66yyCpHcQ --exec "echo %(title)q"
[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ
[youtube] Jo66yyCpHcQ: Downloading webpage
[youtube] Jo66yyCpHcQ: Downloading ios player API JSON
[youtube] Jo66yyCpHcQ: Downloading android player API JSON
[youtube] Jo66yyCpHcQ: Downloading m3u8 information
[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4
[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm
[download] 100% of 4.80KiB in 00:00:00 at 31.58KiB/s
[Merger] Merging formats into ""&echo(&echo(pwned&rem( [Jo66yyCpHcQ].mkv"
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)
[Exec] Executing command: echo "\"&echo(&echo(pwned&rem("
"\"
pwned
Patches
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.
Workarounds
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:
- Avoid using any output template expansion in --exec other than {} (filepath).
- If expansion in --exec is needed, verify the fields you are using do not contain ", | or &.
- Instead of using --exec, write the info json and load the fields from it instead.
References
- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg
- https://nvd.nist.gov/vuln/detail/CVE-2023-40581
- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24
- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044
- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e
| URL | Type | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"resource": "yt-dlp",
"resource_purl": "pkg:pypi/yt-dlp@2026.8.19",
"upstream_fixed_in": "2023.09.24"
},
"package": {
"ecosystem": "Homebrew",
"name": "yewtube",
"purl": "pkg:brew/yewtube"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.13.1_4"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "registry",
"upstream_evidence": [
{
"ecosystem": "PyPI",
"key": "pkg:pypi/yt-dlp@2026.8.19",
"name": "yt-dlp",
"resource": "yt-dlp",
"strategy": "registry",
"subject_version": "2026.8.19"
}
]
},
"details": "### 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\u0027s `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: \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: \uff02\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 \"\uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file \uff02\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",
"id": "BREW-yewtube-CVE-2023-40581",
"modified": "2026-09-10T21:31:39Z",
"published": "2026-08-13T17:55:05Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-40581"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
},
{
"type": "PACKAGE",
"url": "https://github.com/yt-dlp/yt-dlp"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": " yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`",
"upstream": [
"GHSA-42h4-v29r-42qg",
"CVE-2023-40581",
"PYSEC-2026-2064"
]
}
BREW-YT-DLP-CVE-2023-40581 (CVE-2023-40581)
Vulnerability from osv_homebrew – Published: 2026-08-13 17:55 – Updated: 2026-09-10 21:31 – Source websiteyt-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.
| URL | Type | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||
{
"affected": [
{
"ecosystem_specific": {
"fix": "bump",
"range_state": "fixed",
"upstream_fixed_in": "2023.09.24"
},
"package": {
"ecosystem": "Homebrew",
"name": "yt-dlp",
"purl": "pkg:brew/yt-dlp"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2026.7.4"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"database_specific": {
"confidence": "high",
"source": "matched",
"strategy": "git",
"upstream_evidence": [
{
"ecosystem": "GIT",
"key": "https://github.com/yt-dlp/yt-dlp",
"name": "https://github.com/yt-dlp/yt-dlp",
"strategy": "git",
"subject_version": "2026.8.19"
},
{
"ecosystem": "PyPI",
"key": "pkg:pypi/yt-dlp@2026.8.19",
"name": "yt-dlp",
"strategy": "registry",
"subject_version": "2026.8.19"
}
]
},
"details": "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\u0027s `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",
"id": "BREW-yt-dlp-CVE-2023-40581",
"modified": "2026-09-10T21:31:39Z",
"published": "2026-08-13T17:55:05Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
},
{
"type": "ADVISORY",
"url": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/40xxx/CVE-2023-40581.json"
},
{
"type": "ADVISORY",
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-40581"
},
{
"type": "FIX",
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
}
],
"schema_version": "1.7.3",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "yt-dlp command injection when using `%q` in `--exec` on Windows",
"upstream": [
"CVE-2023-40581",
"GHSA-42h4-v29r-42qg",
"PYSEC-2026-2064"
]
}
CVE-2023-40581 (GCVE-0-2023-40581)
Vulnerability from cvelistv5 – Published: 2023-09-25 18:54 – Updated: 2024-09-24 14:48- CWE-78 - Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
| URL | Tags |
|---|---|
| https://github.com/yt-dlp/yt-dlp/security/advisor… | x_refsource_CONFIRM |
| https://github.com/yt-dlp/yt-dlp/commit/de015e930… | x_refsource_MISC |
| https://github.com/yt-dlp/yt-dlp-nightly-builds/r… | x_refsource_MISC |
| https://github.com/yt-dlp/yt-dlp/releases/tag/202… | x_refsource_MISC |
| https://github.com/yt-dlp/yt-dlp/releases/tag/202… | x_refsource_MISC |
| Vendor | Product | Version | |
|---|---|---|---|
| yt-dlp | yt-dlp |
Affected:
>= 2021.04.11, < 2023.09.24
Affected: < nightly 2023.09.24.003044 |
|
| yt-dlp_project | yt-dlp |
Affected:
2021.04.11 , < 2023.09.24
(custom)
Affected: 0 , < nightly 2023.09.24.003044 (custom) cpe:2.3:a:yt-dlp_project:yt-dlp:-:*:*:*:*:*:*:* |
{
"containers": {
"adp": [
{
"providerMetadata": {
"dateUpdated": "2024-08-02T18:38:50.806Z",
"orgId": "af854a3a-2127-422b-91ae-364da2661108",
"shortName": "CVE"
},
"references": [
{
"name": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg",
"tags": [
"x_refsource_CONFIRM",
"x_transferred"
],
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"name": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e",
"tags": [
"x_refsource_MISC",
"x_transferred"
],
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
},
{
"name": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044",
"tags": [
"x_refsource_MISC",
"x_transferred"
],
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"name": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11",
"tags": [
"x_refsource_MISC",
"x_transferred"
],
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"name": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24",
"tags": [
"x_refsource_MISC",
"x_transferred"
],
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
}
],
"title": "CVE Program Container"
},
{
"affected": [
{
"cpes": [
"cpe:2.3:a:yt-dlp_project:yt-dlp:-:*:*:*:*:*:*:*"
],
"defaultStatus": "unknown",
"product": "yt-dlp",
"vendor": "yt-dlp_project",
"versions": [
{
"lessThan": "2023.09.24",
"status": "affected",
"version": "2021.04.11",
"versionType": "custom"
},
{
"lessThan": "nightly 2023.09.24.003044",
"status": "affected",
"version": "0",
"versionType": "custom"
}
]
}
],
"metrics": [
{
"other": {
"content": {
"id": "CVE-2023-40581",
"options": [
{
"Exploitation": "none"
},
{
"Automatable": "no"
},
{
"Technical Impact": "total"
}
],
"role": "CISA Coordinator",
"timestamp": "2024-09-24T14:45:30.642943Z",
"version": "2.0.3"
},
"type": "ssvc"
}
}
],
"providerMetadata": {
"dateUpdated": "2024-09-24T14:48:55.952Z",
"orgId": "134c704f-9b21-4f2e-91b3-4a467353bcc0",
"shortName": "CISA-ADP"
},
"title": "CISA ADP Vulnrichment"
}
],
"cna": {
"affected": [
{
"product": "yt-dlp",
"vendor": "yt-dlp",
"versions": [
{
"status": "affected",
"version": "\u003e= 2021.04.11, \u003c 2023.09.24"
},
{
"status": "affected",
"version": "\u003c nightly 2023.09.24.003044"
}
]
}
],
"descriptions": [
{
"lang": "en",
"value": "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\u0027s `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"
}
],
"metrics": [
{
"cvssV3_1": {
"attackComplexity": "HIGH",
"attackVector": "NETWORK",
"availabilityImpact": "HIGH",
"baseScore": 8.4,
"baseSeverity": "HIGH",
"confidentialityImpact": "HIGH",
"integrityImpact": "HIGH",
"privilegesRequired": "NONE",
"scope": "CHANGED",
"userInteraction": "REQUIRED",
"vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
"version": "3.1"
}
}
],
"problemTypes": [
{
"descriptions": [
{
"cweId": "CWE-78",
"description": "CWE-78: Improper Neutralization of Special Elements used in an OS Command (\u0027OS Command Injection\u0027)",
"lang": "en",
"type": "CWE"
}
]
}
],
"providerMetadata": {
"dateUpdated": "2023-09-25T18:54:00.204Z",
"orgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
"shortName": "GitHub_M"
},
"references": [
{
"name": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg",
"tags": [
"x_refsource_CONFIRM"
],
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"name": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e",
"tags": [
"x_refsource_MISC"
],
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
},
{
"name": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044",
"tags": [
"x_refsource_MISC"
],
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"name": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11",
"tags": [
"x_refsource_MISC"
],
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"name": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24",
"tags": [
"x_refsource_MISC"
],
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
}
],
"source": {
"advisory": "GHSA-42h4-v29r-42qg",
"discovery": "UNKNOWN"
},
"title": "yt-dlp command injection when using `%q` in `--exec` on Windows"
}
},
"cveMetadata": {
"assignerOrgId": "a0819718-46f1-4df5-94e2-005712e83aaa",
"assignerShortName": "GitHub_M",
"cveId": "CVE-2023-40581",
"datePublished": "2023-09-25T18:54:00.204Z",
"dateReserved": "2023-08-16T18:24:02.391Z",
"dateUpdated": "2024-09-24T14:48:55.952Z",
"state": "PUBLISHED"
},
"dataType": "CVE_RECORD",
"dataVersion": "5.1"
}
GHSA-42H4-V29R-42QG
Vulnerability from github – Published: 2023-09-25 17:33 – Updated: 2023-09-26 13:57Impact
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.
However, 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.
Support for output template expansion in --exec, along with this vulnerable behavior, was added to yt-dlp in version 2021.04.11.
> yt-dlp https://youtu.be/Jo66yyCpHcQ --exec "echo %(title)q"
[youtube] Extracting URL: https://youtu.be/Jo66yyCpHcQ
[youtube] Jo66yyCpHcQ: Downloading webpage
[youtube] Jo66yyCpHcQ: Downloading ios player API JSON
[youtube] Jo66yyCpHcQ: Downloading android player API JSON
[youtube] Jo66yyCpHcQ: Downloading m3u8 information
[info] Jo66yyCpHcQ: Downloading 1 format(s): 135+251
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4
[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s
[download] Destination: "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm
[download] 100% of 4.80KiB in 00:00:00 at 31.58KiB/s
[Merger] Merging formats into ""&echo(&echo(pwned&rem( [Jo66yyCpHcQ].mkv"
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)
Deleting original file "&echo(&echo(pwned&rem( [Jo66yyCpHcQ].f251.webm (pass -k to keep)
[Exec] Executing command: echo "\"&echo(&echo(pwned&rem("
"\"
pwned
Patches
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.
Workarounds
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:
- Avoid using any output template expansion in --exec other than {} (filepath).
- If expansion in --exec is needed, verify the fields you are using do not contain ", | or &.
- Instead of using --exec, write the info json and load the fields from it instead.
References
- https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg
- https://nvd.nist.gov/vuln/detail/CVE-2023-40581
- https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24
- https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044
- https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "yt-dlp"
},
"ranges": [
{
"events": [
{
"introduced": "2021.04.11"
},
{
"fixed": "2023.09.24"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2023-40581"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2023-09-25T17:33:40Z",
"nvd_published_at": "2023-09-25T19:15:09Z",
"severity": "HIGH"
},
"details": "### 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\u0027s `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: \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4\n[download] 100% of 4.85KiB in 00:00:00 at 60.20KiB/s\n[download] Destination: \uff02\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 \"\uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].mkv\"\nDeleting original file \uff02\u0026echo(\u0026echo(pwned\u0026rem( [Jo66yyCpHcQ].f135.mp4 (pass -k to keep)\nDeleting original file \uff02\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",
"id": "GHSA-42h4-v29r-42qg",
"modified": "2023-09-26T13:57:26Z",
"published": "2023-09-25T17:33:40Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-42h4-v29r-42qg"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-40581"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/commit/de015e930747165dbb8fcd360f8775fd973b7d6e"
},
{
"type": "PACKAGE",
"url": "https://github.com/yt-dlp/yt-dlp"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2023.09.24.003044"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2021.04.11"
},
{
"type": "WEB",
"url": "https://github.com/yt-dlp/yt-dlp/releases/tag/2023.09.24"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": " yt-dlp on Windows vulnerable to `--exec` command injection when using `%q`"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.