Open Redirect Affecting better-auth package, versions <1.1.6


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.06% (28th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Open Redirect vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-BETTERAUTH-8554003
  • published31 Dec 2024
  • disclosed30 Dec 2024
  • creditjamesjulich

Introduced: 30 Dec 2024

NewCVE-2024-56734  (opens in a new tab)
CWE-601  (opens in a new tab)

How to fix?

Upgrade better-auth to version 1.1.6 or higher.

Overview

better-auth is a The most comprehensive authentication library for TypeScript.

Affected versions of this package are vulnerable to Open Redirect via the auth/verify-email endpoint, due to improper validation of callbackURL parameter through the originCheckMiddleware function.

Note: This vulnerability impacts users relying on email verification links generated by the library.

Workaround

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
            }
         }
    }
})

PoC

https://example.com/auth/verify-email?token=abcd1234&callbackURL=https://malicious-site.com

References

CVSS Scores

version 4.0
version 3.1