fix(origin-check): prevent URLs with double slashes from being trusted

This commit is contained in:
Bereket Engida
2025-02-24 12:25:04 +03:00
parent d9c57e1f56
commit 24659aefc3

View File

@@ -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}`);