Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS04amh3LTZwamotODcyM84ABC0_
Better Auth has an Open Redirect Vulnerability in Verify Email Endpoint
Summary
An open redirect vulnerability has been identified in the verify email endpoint of Better Auth, potentially allowing attackers to redirect users to malicious websites. This issue affects users relying on email verification links generated by the library.
Affected Versions
- All versions prior to v1.1.6.
Impact
Attackers could craft malicious email verification links that exploit the redirect functionality to send users to untrusted domains. This can result in:
- Phishing attacks – Users may unknowingly enter sensitive information on fake login pages.
- Reputation damage – Trust issues for applications using Better Auth.
Vulnerability Details
The verify email callback endpoint accepts a callbackURL
parameter. Unlike other verification methods, email verification only uses JWT to verify and redirect without proper validation of the target domain. The origin checker is bypassed in this scenario because it only checks for POST
requests. An attacker can manipulate this parameter to redirect users to arbitrary URLs controlled by the attacker.
Example Exploit:
https://example.com/auth/verify-email?token=abcd1234&callbackURL=https://malicious-site.com
Patches
Upgrade to Better Auth v1.1.6 or later. This version enforces domain validation for callbackURL
for /verify-email
path and for all other GET
endpoints.
Workarounds
You can also use hooks to pre-check URLs in your auth instance to prevent this without upgrading:
const auth = betterAuth({
hooks: {
before: (ctx) => {
if (ctx.path === "/verify-email") {
const callbackURL = ctx.query.callbackURL; // Check if this is a trusted callback URL or not
}
}
}
})
Permalink: https://github.com/advisories/GHSA-8jhw-6pjj-8723JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS04amh3LTZwamotODcyM84ABC0_
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 24 days ago
Updated: 24 days ago
EPSS Percentage: 0.00061
EPSS Percentile: 0.27555
Identifiers: GHSA-8jhw-6pjj-8723, CVE-2024-56734
References:
- https://github.com/better-auth/better-auth/security/advisories/GHSA-8jhw-6pjj-8723
- https://github.com/better-auth/better-auth/commit/deb3d73aea90d0468d92723f4511542b593e522f
- https://nvd.nist.gov/vuln/detail/CVE-2024-56734
- https://github.com/advisories/GHSA-8jhw-6pjj-8723
Blast Radius: 1.0
Affected Packages
npm:better-auth
Dependent packages: 0Dependent repositories: 0
Downloads: 83,730 last month
Affected Version Ranges: < 1.1.6
Fixed in: 1.1.6
All affected versions: 0.0.1, 0.0.2, 0.0.4, 0.0.5, 0.0.6, 0.0.7, 0.0.8, 0.1.0, 0.2.0, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 0.2.8, 0.2.9, 0.2.10, 0.2.11, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.4.0, 0.4.1, 0.4.2, 0.4.3, 0.4.4, 0.4.5, 0.4.6, 0.4.7, 0.4.8, 0.4.9, 0.4.10, 0.4.11, 0.4.12, 0.4.13, 0.5.0, 0.5.1, 0.5.2, 0.5.3, 0.6.0, 0.6.1, 0.6.2, 0.7.0, 0.7.1, 0.7.2, 0.7.3, 0.7.4, 0.7.5, 0.8.0, 0.8.1, 0.8.2, 0.8.3, 0.8.4, 0.8.5, 0.8.6, 0.8.7, 0.8.8, 1.0.0, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8, 1.0.9, 1.0.10, 1.0.11, 1.0.12, 1.0.13, 1.0.14, 1.0.15, 1.0.16, 1.0.17, 1.0.18, 1.0.19, 1.0.20, 1.0.21, 1.0.22, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5
All unaffected versions: 1.1.6, 1.1.7, 1.1.8, 1.1.9, 1.1.10, 1.1.11, 1.1.12, 1.1.13, 1.1.14