Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apps/dashboard/src/app/login/isValidEncodedRedirectPath.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
export function isValidEncodedRedirectPath(encodedPath: string): boolean {
try {
// Decode the URI component
const decodedPath = decodeURIComponent(encodedPath);
// ensure the path always starts with a _single_ slash
// double slash could be interpreted as `//example.com` which is not allowed
return decodedPath.startsWith("/") && !decodedPath.startsWith("//");
if (!decodedPath.startsWith("/")) {
return false;
}
const url = new URL(decodedPath, "https://thirdweb.com");
return url.hostname === "thirdweb.com";
} catch {
// If decoding fails, return false
return false;
Expand Down
Loading