Skip to content

Commit a2712ff

Browse files
committed
fix(origin-check): prevent URLs with double slashes from being trusted
1 parent 5b1d88d commit a2712ff

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/better-auth/src/api/middlewares/origin-check.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ export const originCheckMiddleware = createAuthMiddleware(async (ctx) => {
4747
const isTrustedOrigin = trustedOrigins.some(
4848
(origin) =>
4949
matchesPattern(url, origin) ||
50-
(url?.startsWith("/") && label !== "origin" && !url.includes(":")),
50+
(url?.startsWith("/") &&
51+
label !== "origin" &&
52+
!url.includes(":") &&
53+
!url.includes("//")),
5154
);
5255
if (!isTrustedOrigin) {
5356
ctx.context.logger.error(`Invalid ${label}: ${url}`);

0 commit comments

Comments
 (0)