The analysis of the security advisory and the associated patch commit 2726572520238356bcf64aba2040228648b44c82 points directly to the _make_cmd method within the CurlFD class in yt_dlp/downloader/external.py as the source of the vulnerability. The vulnerability description explains that passing cookies as a simple header to curl (e.g., --cookie "key=value") causes them to be leaked on redirects. The patch removes this exact logic:
- cookie_header = self.ydl.cookiejar.get_cookie_header(info_dict['url'])
- if cookie_header:
- cmd += ['--cookie', cookie_header]
This code snippet is replaced with a more secure mechanism that instructs curl to use its cookie engine by either reading cookies from stdin (--cookie -) or from a temporary file. This ensures that cookies are only sent to the domains for which they are scoped. Therefore, the CurlFD._make_cmd function is the precise location of the vulnerable code that constructs the insecure command, making it the key function that would be observed in a runtime profile when the vulnerability is triggered.