[YoutubeDL] urlopen: disable the 'file:' protocol (#8227)
If someone is running youtube-dl on a server to deliver files, the user could input 'file:///some/important/file' and youtube-dl would save that file as a video giving access to sensitive information to the user. 'file:' urls can be filtered, but the user can use an URL to a crafted m3u8 manifest like: #EXTM3U #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:10.0 file:///etc/passwd #EXT-X-ENDLIST With this patch 'file:' URLs raise URLError like for unknown protocols.
This commit is contained in:
parent
40cf7fcbd2
commit
e37afbe0b8
2 changed files with 14 additions and 3 deletions
|
@ -1986,8 +1986,14 @@ class YoutubeDL(object):
|
|||
https_handler = make_HTTPS_handler(self.params, debuglevel=debuglevel)
|
||||
ydlh = YoutubeDLHandler(self.params, debuglevel=debuglevel)
|
||||
data_handler = compat_urllib_request_DataHandler()
|
||||
opener = compat_urllib_request.build_opener(
|
||||
proxy_handler, https_handler, cookie_processor, ydlh, data_handler)
|
||||
unknown_handler = compat_urllib_request.UnknownHandler()
|
||||
handlers = (proxy_handler, https_handler, cookie_processor, ydlh, data_handler, unknown_handler)
|
||||
# we don't use build_opener because it automatically adds FileHandler,
|
||||
# which can be used for malicious purposes (see
|
||||
# https://github.com/rg3/youtube-dl/issues/8227)
|
||||
opener = compat_urllib_request.OpenerDirector()
|
||||
for handler in handlers:
|
||||
opener.add_handler(handler)
|
||||
|
||||
# Delete the default user-agent header, which would otherwise apply in
|
||||
# cases where our custom HTTP handler doesn't come into play
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue