Packages / better-auth / Security

LowVulnerabilityGHSA-36rg-gfq2-3h56CVE-2025-53535Published 7 Jul 2025

Better Auth Open Redirect Vulnerability in originCheck Middleware Affects Multiple Routes

Affected releases · better-auth

  • 1.x1.0.0 – 1.2.9Fixed in 1.2.10
  • 0.8.x and older0.0.1 – 0.8.8No fix, no longer updated

On 1.x, the newest line:

npm install better-auth@1.2.10
1.x
  1. Affected

    1.0.0 – 1.2.9

    54 releases

  2. Fixed

    1.2.10 – 1.7.12

    115 releases, latest

0.x
  1. Affected

    0.0.1 – 0.8.8

    61 releases

230 stable releases of better-auth, oldest to newest, one row per major.

Is your project affected?

Paste your package.json, or type the range you declare for better-auth. It is read in your browser and sent nowhere.

What happens

Summary

An open redirect has been found in the originCheck middleware function, which affects the following routes: /verify-email, /reset-password/:token, /delete-user/callback, /magic-link/verify, /oauth-proxy-callback.

Details

In the matchesPattern function, url.startsWith( can be deceived with a url that starts with one of the trustedOrigins.

		const matchesPattern = (url: string, pattern: string): boolean => {
			if (url.startsWith("/")) {
				return false;
			}
			if (pattern.includes("*")) {
				return wildcardMatch(pattern)(getHost(url));
			}
			return url.startsWith(pattern);
		};

Open Redirect PoCs

export const auth = betterAuth({
	baseURL: 'http://localhost:3000',
	trustedOrigins: [
		"http://trusted.com"
	],
	emailAndPassword: {
		...
	},
})

/reset-password/:token

/verify-email

/delete-user/callback

/magic-link/verify

/oauth-proxy-callback

Impact

Untrusted open redirects in various routes.