mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-27 01:16:55 -05:00
fix(origin-check): prevent URLs with double slashes from being trusted
This commit is contained in:
@@ -47,7 +47,10 @@ export const originCheckMiddleware = createAuthMiddleware(async (ctx) => {
|
||||
const isTrustedOrigin = trustedOrigins.some(
|
||||
(origin) =>
|
||||
matchesPattern(url, origin) ||
|
||||
(url?.startsWith("/") && label !== "origin" && !url.includes(":")),
|
||||
(url?.startsWith("/") &&
|
||||
label !== "origin" &&
|
||||
!url.includes(":") &&
|
||||
!url.includes("//")),
|
||||
);
|
||||
if (!isTrustedOrigin) {
|
||||
ctx.context.logger.error(`Invalid ${label}: ${url}`);
|
||||
|
||||
Reference in New Issue
Block a user