The vulnerability is an OS command injection in yt-dlp that can be triggered when using the --netrc-cmd option with a specially crafted URL. The root cause of the vulnerability lies in the InfoExtractor._get_netrc_login_info function, which is responsible for handling the --netrc-cmd functionality. This function would construct and execute a shell command using the netrc_machine value, which is derived from the input URL. The vulnerability existed because this netrc_machine value was not sanitized, allowing shell metacharacters to be passed to the command, leading to arbitrary command execution.
The vulnerability was exploitable through several extractors that dynamically determine the netrc_machine from the URL's hostname. The advisory specifically mentions GetCourseRuIE, TeachableIE, and TeachableCourseIE. The _real_extract methods of these extractors used overly permissive regular expressions to parse the URL, which allowed malicious hostnames containing shell metacharacters to be extracted and passed to the vulnerable _get_netrc_login_info function.
The patch addresses the vulnerability at two levels. First, it adds strict validation to the _get_netrc_login_info function to ensure that the netrc_machine value only contains a safe set of characters. Second, it tightens the URL validation regular expressions in the affected extractors to prevent them from parsing malicious hostnames in the first place. This two-pronged approach effectively mitigates the command injection vulnerability.