Source: security-advisories@github.com
yt-dlp is a command-line audio/video downloader. Starting in version 2023.06.21 and prior to version 2026.02.21, when yt-dlp's `--netrc-cmd` command-line option (or `netrc_cmd` Python API parameter) is used, an attacker could achieve arbitrary command injection on the user's system with a maliciously crafted URL. yt-dlp maintainers assume the impact of this vulnerability to be high for anyone who uses `--netrc-cmd` in their command/configuration or `netrc_cmd` in their Python scripts. Even though the maliciously crafted URL itself will look very suspicious to many users, it would be trivial for a maliciously crafted webpage with an inconspicuous URL to covertly exploit this vulnerability via HTTP redirect. Users without `--netrc-cmd` in their arguments or `netrc_cmd` in their scripts are unaffected. No evidence has been found of this exploit being used in the wild. yt-dlp version 2026.02.21 fixes this issue by validating all netrc "machine" values and raising an error upon unexpected input. As a workaround, users who are unable to upgrade should avoid using the `--netrc-cmd` command-line option (or `netrc_cmd` Python API parameter), or they should at least not pass a placeholder (`{}`) in their `--netrc-cmd` argument.
yt-dlp, a popular command-line downloader, is vulnerable to command injection when the --netrc-cmd option is used with a maliciously crafted URL. This allows attackers to execute arbitrary commands on a user's system, potentially leading to complete system compromise. Users who utilize this option are at high risk and should immediately update or implement the provided workarounds.
Step 1: Victim Configuration: The victim uses yt-dlp with the --netrc-cmd option (or netrc_cmd in a Python script). This option specifies a command to be executed, potentially using the 'machine' value from a .netrc file or a URL.
Step 2: Malicious URL Delivery: The attacker crafts a malicious URL containing a specially crafted 'machine' value. This URL could be delivered through various means, such as a phishing email, a compromised website, or a social engineering attack.
Step 3: yt-dlp Processing: The victim's yt-dlp instance processes the malicious URL. The software extracts the 'machine' value from the URL.
Step 4: Command Injection: The extracted 'machine' value, which contains malicious commands, is passed to the command specified by --netrc-cmd without proper sanitization or validation.
Step 5: Command Execution: The operating system executes the attacker-controlled commands, allowing the attacker to gain control of the victim's system, potentially leading to data theft, system compromise, or further malicious activities.
The vulnerability stems from insufficient input validation within yt-dlp when processing the --netrc-cmd option. Specifically, the software fails to properly sanitize the 'machine' value extracted from a crafted URL before passing it to the command specified by --netrc-cmd. This allows an attacker to inject arbitrary commands into the command execution context. The root cause is a lack of proper input validation and sanitization of user-controlled data (the URL) before it is used in a system command. The software trusts the 'machine' value, assuming it's safe, without verifying its contents. This leads to a command injection vulnerability, enabling attackers to execute malicious code.
While no specific APTs are directly linked to this vulnerability at this time, any threat actor with the capability to craft malicious URLs and target users of yt-dlp could exploit it. This includes both financially motivated actors and nation-state actors. CISA KEV status: Not Applicable (as of the provided information, no KEV entry exists).
Monitor command-line arguments used with yt-dlp, specifically for the --netrc-cmd option. Unusual or unexpected command arguments should be investigated.
Analyze network traffic for suspicious URLs, especially those containing unusual characters or patterns in the 'machine' value, which could indicate command injection attempts.
Review system logs for processes spawned by yt-dlp and their associated command lines. Look for any unexpected or malicious commands being executed.
Implement file integrity monitoring to detect any unauthorized changes to system files that could be caused by a successful exploit.
Monitor for outbound network connections from systems running yt-dlp, especially to suspicious IP addresses or domains.
Upgrade to yt-dlp version 2026.02.21 or later. This version includes a fix that validates the 'machine' values and raises an error upon unexpected input, preventing command injection.
If upgrading is not immediately possible, avoid using the --netrc-cmd command-line option (or netrc_cmd Python API parameter).
If using --netrc-cmd is unavoidable, do not pass a placeholder ({}) in the --netrc-cmd argument. This reduces the attack surface.
Implement a Web Application Firewall (WAF) or Intrusion Detection System (IDS) to detect and block malicious URLs containing command injection payloads.
Educate users about the risks of clicking on suspicious links and the importance of keeping software up to date.