The vulnerability is a bypass of CVE-2024-38519 and stems from an incomplete fix that left dangerous OS-shortcut file extensions (.desktop, .url, .webloc) in a global allowlist. The core of the issue lies in yt_dlp/utils/_utils.py, specifically within the _UnsafeExtensionError.sanitize_extension method, which performed extension validation against this flawed list.
The exploit is triggered when yt-dlp processes remote, attacker-controlled content (e.g., an HLS manifest for subtitles via --write-subs) that specifies a malicious file extension. The application's file creation process calls utility functions like _change_extension, which in turn uses _UnsafeExtensionError.sanitize_extension for validation. Because the dangerous extensions were on the allowlist, the validation would pass, and a malicious file (e.g., MyVideo.en.desktop) would be written to the user's filesystem, leading to potential code execution through social engineering.
The patch rectifies this by removing the unsafe extensions from the global ALLOWED_EXTENSIONS set and introducing a mechanism to pass a context-specific list of allowed extensions (_allowed_exts) to the validation functions. This ensures that only the intended feature (--write-link) can create shortcut files, while all other file-writing operations correctly reject them.