Skip to content

Commit cd6b912

Browse files
committed
[MNY-310] Improve login redirect path validation
1 parent c7ff3b1 commit cd6b912

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

apps/dashboard/src/app/login/isValidEncodedRedirectPath.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
export function isValidEncodedRedirectPath(encodedPath: string): boolean {
22
try {
3-
// Decode the URI component
43
const decodedPath = decodeURIComponent(encodedPath);
5-
// ensure the path always starts with a _single_ slash
6-
// double slash could be interpreted as `//example.com` which is not allowed
7-
return decodedPath.startsWith("/") && !decodedPath.startsWith("//");
4+
if (!decodedPath.startsWith("/")) {
5+
return false;
6+
}
7+
const url = new URL(decodedPath, "https://thirdweb.com");
8+
return url.hostname === "thirdweb.com";
89
} catch {
910
// If decoding fails, return false
1011
return false;

0 commit comments

Comments
 (0)