Summary
Under certain configurations, sessions may be considered valid before two-factor authentication (2FA) is fully completed. This can allow access to authenticated routes without verifying the second factor.
Description
When two-factor authentication is enabled, the authentication flow correctly identifies users who require additional verification and defers full authentication until the second factor is completed.
However, when session.cookieCache is enabled, the session generated during the initial sign-in step may be cached as valid prior to 2FA verification. Subsequent session lookups may then return this cached session without re-evaluating the 2FA requirement.
This results in a situation where session validity can be established before all authentication constraints are satisfied.
Mitigation
- Upgrade to a version of
better-auththat includes the fix for this issue. - Ensure that session caching does not treat sessions as fully authenticated until all required authentication steps, including 2FA, are completed.
- As a temporary workaround, disable
session.cookieCachewhen using two-factor authentication.
Impact
An attacker (or user) with valid primary credentials may gain access to protected application routes without completing the required second authentication factor.
Any application using better-auth with both two-factor authentication and session cookie caching enabled may be affected.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is GHSA-XG6X-H9C9-2M83? GHSA-XG6X-H9C9-2M83 is a critical-severity security vulnerability in better-auth (npm), affecting versions < 1.4.9. It is fixed in 1.4.9.
- Which versions of better-auth are affected by GHSA-XG6X-H9C9-2M83? better-auth (npm) versions < 1.4.9 is affected.
- Is there a fix for GHSA-XG6X-H9C9-2M83? Yes. GHSA-XG6X-H9C9-2M83 is fixed in 1.4.9. Upgrade to this version or later.
- Is GHSA-XG6X-H9C9-2M83 exploitable, and should I be worried? Whether GHSA-XG6X-H9C9-2M83 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-XG6X-H9C9-2M83 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-XG6X-H9C9-2M83? Upgrade
better-authto 1.4.9 or later.