Skip to content

Commit 01135db

Browse files
committed
video_playback: Check "host" parameter validity
1 parent 955e3de commit 01135db

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/invidious/routes/video_playback.cr

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ module Invidious::Routes::VideoPlayback
1414
end
1515

1616
if query_params["host"]? && !query_params["host"].empty?
17-
host = "https://#{query_params["host"]}"
17+
host = query_params["host"]
1818
query_params.delete("host")
1919
else
20-
host = "https://r#{fvip}---#{mns.pop}.googlevideo.com"
20+
host = "r#{fvip}---#{mns.pop}.googlevideo.com"
2121
end
2222

23+
# Sanity check, to avoid being used as an open proxy
24+
if !host.matches?(/[\w-]+.googlevideo.com/)
25+
return error_template(400, "Invalid \"host\" parameter.")
26+
end
27+
28+
host = "https://#{host}"
2329
url = "/videoplayback?#{query_params}"
2430

2531
headers = HTTP::Headers.new

0 commit comments

Comments
 (0)