GHSA-8jhw-6pjj-8723

Suggest an improvement
Source
https://github.com/advisories/GHSA-8jhw-6pjj-8723
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/12/GHSA-8jhw-6pjj-8723/GHSA-8jhw-6pjj-8723.json
JSON Data
https://api.test.osv.dev/v1/vulns/GHSA-8jhw-6pjj-8723
Aliases
Published
2024-12-30T16:49:12Z
Modified
2024-12-30T18:45:17Z
Severity
  • 7.9 (High) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:H/SI:H/SA:H CVSS Calculator
Summary
Better Auth has an Open Redirect Vulnerability in Verify Email Endpoint
Details

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
            }
         }
    }
})
Database specific
{
    "nvd_published_at": "2024-12-30T17:15:10Z",
    "cwe_ids": [
        "CWE-601"
    ],
    "severity": "HIGH",
    "github_reviewed": true,
    "github_reviewed_at": "2024-12-30T16:49:12Z"
}
References

Affected packages

npm / better-auth

Package

Affected ranges

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