Hotfix: Be more strict with safeRedirectUrl check (#4675)

* Be more strict

* Apply suggestions from code review

Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
Hariom Balhara
2022-09-24 09:40:49 +01:00
committed by GitHub
co-authored by Alex van Andel
parent 682f0c66ff
commit 24635af730
+3 -1
View File
@@ -9,8 +9,10 @@ export const getSafeRedirectUrl = (url = "") => {
throw new Error("Pass an absolute URL");
}
const urlParsed = new URL(url);
// Avoid open redirection security vulnerability
if (![CONSOLE_URL, WEBAPP_URL, WEBSITE_URL].some((u) => url.startsWith(u))) {
if (![CONSOLE_URL, WEBAPP_URL, WEBSITE_URL].some((u) => new URL(u).origin === urlParsed.origin)) {
url = `${WEBAPP_URL}/`;
}