Skip to content

Commit d25cc1f

Browse files
authored
fix: validate redirect parameter to prevent open redirect (#262)
Co-authored-by: Flegma <Flegma@users.noreply.github.com>
1 parent ade8183 commit d25cc1f

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

middleware/auth.global.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ export default defineNuxtRouteMiddleware(async (to, from) => {
7171

7272
if (hasMe && to.path === "/login") {
7373
if (to.query.redirect) {
74-
return navigateTo(decodeURIComponent(to.query.redirect as string));
74+
const redirectPath = decodeURIComponent(to.query.redirect as string);
75+
if (redirectPath.startsWith("/") && !redirectPath.startsWith("//")) {
76+
return navigateTo(redirectPath);
77+
}
7578
}
7679
return navigateTo("/");
7780
}

0 commit comments

Comments
 (0)