GHSA-36rg-gfq2-3h56

Suggest an improvement
Source
https://github.com/advisories/GHSA-36rg-gfq2-3h56
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/07/GHSA-36rg-gfq2-3h56/GHSA-36rg-gfq2-3h56.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-36rg-gfq2-3h56
Aliases
Published
2025-07-07T22:13:14Z
Modified
2025-07-07T22:59:37Z
Severity
  • 2.1 (Low) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N/E:P/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X CVSS Calculator
Summary
Better Auth Open Redirect Vulnerability in originCheck Middleware Affects Multiple Routes
Details

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

image
image 1

/verify-email

image
image

/delete-user/callback

image
image

/magic-link/verify

image
image

/oauth-proxy-callback

image
image

Impact

Untrusted open redirects in various routes.

Database specific
{
    "cwe_ids":  [
        "CWE-601"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2025-07-07T22:13:14Z",
    "nvd_published_at":  "2025-07-07T18:15:28Z",
    "severity":  "LOW"
}
References

Affected packages

npm / better-auth

Package

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
1.2.10

Database specific

last_known_affected_version_range
"<= 1.2.9"
source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2025/07/GHSA-36rg-gfq2-3h56/GHSA-36rg-gfq2-3h56.json"