Skip to content

Commit 43d9b2b

Browse files
authored
fix: onboarding dom-based xss (#1980)
1 parent 1b678e7 commit 43d9b2b

File tree

1 file changed

+5
-0
lines changed
  • apps/dashboard/src/app/(dashboard)/onboarding

1 file changed

+5
-0
lines changed

apps/dashboard/src/app/(dashboard)/onboarding/client.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,15 @@ export function Client() {
134134
try {
135135
const url = new URL(callbackUrl, window.location.origin);
136136
if (url.pathname === "/" || url.pathname === "") return;
137+
// Only allow same-origin redirects with safe protocols
138+
if (url.origin !== window.location.origin) return;
139+
if (url.protocol !== "http:" && url.protocol !== "https:") return;
137140
router.push(callbackUrl);
138141
} catch {
139142
// If callbackUrl is a relative path, check it directly
140143
if (callbackUrl === "/" || callbackUrl === "") return;
144+
// Only allow paths starting with / to prevent protocol-based attacks
145+
if (!callbackUrl.startsWith("/")) return;
141146
router.push(callbackUrl);
142147
}
143148
}, [callbackUrl, router]);

0 commit comments

Comments
 (0)