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:
co-authored by
Alex van Andel
parent
682f0c66ff
commit
24635af730
@@ -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}/`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user