Summary
yt-dlp's integration with the aria2c external downloader fails to properly sanitize parameters for fragmented manifest formats like HLS and DASH, allowing crafted input to control file paths passed to aria2c.
An attacker who can influence yt-dlp download parameters or manifest data may achieve arbitrary file writes, which can result in immediate or subsequent arbitrary code execution depending on the platform.
Affected context
The vulnerability appears when yt-dlp is configured to use aria2c as an external downloader for fragmented streaming formats such as HLS or DASH.
Risk is present when untrusted or attacker-controlled URLs, manifests, or download options are fed into yt-dlp, allowing malicious values to propagate into aria2c arguments.
The issue is particularly dangerous on Windows, where an arbitrary file write can more directly translate into immediate code execution, while on other platforms it typically manifests on the next yt-dlp invocation if critical files are overwritten.
Exploit preconditions
- Attack surface: Command-line use of yt-dlp with aria2c as the external downloader for fragmented streams (HLS/DASH).
- Required access: Ability to supply or influence the video/audio URL, manifest, or command-line parameters processed by yt-dlp, such that they control fields passed to aria2c.
- Trigger point: Download initiation of a fragmented stream where yt-dlp constructs aria2c command arguments from attacker-influenced input.
- Why exploitation is possible: yt-dlp performs insufficient sanitization and validation of user-controlled values before embedding them into aria2c command parameters, enabling injection-like control over file paths and write targets.
Why this happens
This vulnerability stems from improper neutralization of special elements in command and configuration arguments (CWE-74).
yt-dlp treats user-supplied or manifest-derived data as trusted and passes it on to aria2c with inadequate escaping or validation, allowing attackers to manipulate output file paths or related options.
Conceptually, this is an injection flaw where untrusted input crosses a trust boundary into an external tool invocation without being constrained to a safe set of values or patterns.
Potential impact
- Arbitrary file creation or overwrite within the user's filesystem.
- Overwriting application or configuration files that may be executed later.
- Immediate arbitrary code execution on Windows by targeting executable or startup locations.
- Arbitrary code execution on non-Windows platforms upon subsequent yt-dlp runs if critical scripts or binaries are replaced.
- Persistent compromise of the local environment through trojanized files or altered configurations.
General mitigation guidance
Mitigation should focus on strictly controlling what data can be passed from yt-dlp into external downloaders like aria2c.
Defensive patterns include:
- Validating and constraining file paths, output options, and aria2c parameters to a safe subset rather than forwarding raw user input.
- Employing robust escaping and neutralization for special characters in command-line arguments.
- Separating user-controlled data from control parameters by using structured APIs instead of constructing shell-like command strings.
- Running downloads with least-privilege permissions and avoiding execution from directories where arbitrary file writes could be leveraged for code execution.
- Treating remote manifests and URLs as untrusted data and applying schema or pattern checks before using them to build downloader options.
How teams detect issues like this
Detection typically involves reviewing how external tools are invoked and where untrusted data flows into command construction.
Useful strategies include:
- Static analysis rules that flag concatenation of user-controlled strings into command-line arguments or downloader options.
- Code review checklists that focus on external process execution, ensuring arguments are validated and constrained.
- Runtime logging of external downloader invocations and parameters, making it easier to spot anomalous or unexpected file paths.
- Policy enforcement in CI/CD pipelines that prohibit unsafe command construction patterns or require security sign-off for integrations with external tools.

