Skip to main content

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

CVE-2024-22423

Severity High
Score 8.3/10

Summary

yt-dlp is a youtube-dl fork with additional features and fixes. The patch that addressed CVE-2023-40581 attempted to prevent RCE when using "--exec" with "%q" by replacing double quotes with two double quotes. However, this escaping is insufficient, and still allows expansion of environment variables. Support for output template expansion in "--exec", along with this vulnerable behavior, was added to 'yt-dlp' in vulnerable versions. The latest version fixes this issue by properly escaping '%'. It replaces them with "%%cd:~,%", a variable that expands to nothing, leaving only the leading percent. 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 '&'; and/or instead of using '--exec', write the info JSON and load the fields from it instead. This issue affects yt-dlp versions 2021.4.11 through 2024.4.8.232708.dev0.

  • HIGH
  • NETWORK
  • HIGH
  • CHANGED
  • REQUIRED
  • NONE
  • HIGH
  • HIGH

CWE-78 - OS Command Injection

The OS command injection weakness (also known as shell injection) is a vulnerability which enables an attacker to run arbitrary OS commands on a server. This is done by modifying the intended downstream OS command and injecting arbitrary commands, enabling the execution of unauthorized OS commands. This has the potential to fully compromise the application along with all of its data, and, if the compromised process does not follow the principle of least privileges, it may compromise other parts of the hosting infrastructure as well. This weakness is listed as number ten in the 'CWE Top 25 Most Dangerous Software Weaknesses'.

Advisory Timeline

  • Published