mirror of
https://github.com/iv-org/invidious.git
synced 2026-11-25 23:41:37 +00:00
fix: fix SSRF vulnerability in videoplayback in the passed host query parameter (#6174)
Closes https://github.com/iv-org/invidious/issues/6090
This commit is contained in:
@@ -22,8 +22,11 @@ module Invidious::Routes::VideoPlayback
|
|||||||
host = "r#{fvip}---#{mns.pop}.googlevideo.com"
|
host = "r#{fvip}---#{mns.pop}.googlevideo.com"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sanity check, to avoid being used as an open proxy
|
# Sanity check, to avoid being used as an open proxy.
|
||||||
if !host.matches?(/[\w-]+\.(?:googlevideo|c\.youtube)\.com/)
|
# Anchored (`\A`/`\z`), so the hostname must consist *entirely* of a
|
||||||
|
# googlevideo.com / c.youtube.com address — an attacker-controlled suffix
|
||||||
|
# like `evil.googlevideo.com.attacker.net` must not pass.
|
||||||
|
if !host.matches?(/\A[\w-]+\.(?:googlevideo|c\.youtube)\.com\z/)
|
||||||
return Errors.error_template(400, "Invalid \"host\" parameter.")
|
return Errors.error_template(400, "Invalid \"host\" parameter.")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user