Vulnerabilities in pkg:npm/better-auth

PACKAGE
Advisory Identifier: GHSA-569q-mpph-wgww
Advisory Summary

CVE-2025-71401 is a HIGH denial of service vulnerability (CWE-770: Allocation of Resources Without Limits or Throttling) affecting Better auth libraries in the npm ecosystem. The issue involves better auth affected by external request basepath modification dos. Remediation is available by upgrading affected packages to version 1.4.2.

23 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/better-auth

23 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/better-auth. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-569q-mpph-wgww CVE-2025-71401 HIGH Better Auth affected by external request basePath modification DoS
GHSA-3q45-2fh7-66cj - CRITICAL Duplicate Advisory: better-auth has an external request basePath modification DoS
GHSA-qq9h-g4jm-xgf3 - HIGH Better Auth: Account takeover via pre-account hijacking on magic-link and email-OTP sign-in
GHSA-7w99-5wm4-3g79 CVE-2026-53518 HIGH @better-auth/oauth-provider's OAuth authorization-code grant allows concurrent redemption when two token requests race the find-then-delete primitive
GHSA-392p-2q2v-4372 CVE-2026-53517 HIGH Better Auth: OAuth refresh-token rotation forks the token family on concurrent redemption
GHSA-fmh4-wcc4-5jm3 CVE-2026-53514 HIGH Better Auth vulnerable to unauthorized invitation acceptance via unverified email match in organization plugin
GHSA-pw9m-5jxm-xr6h CVE-2026-53512 CRITICAL Better Auth: OAuth refresh-token replay via missing client authentication on oidc-provider and mcp plugins
GHSA-g38m-r43w-p2q7 CVE-2026-53516 HIGH Better Auth has an account takeover issue via OAuth auto-link to unverified pre-registered email
GHSA-2vg6-77g8-24mp - LOW Better Auth: Stale sessions persist after user deletion across admin, anonymous, and SCIM flows
GHSA-9h47-pqcx-hjr4 - HIGH Better Auth has insecure cryptographic defaults in oidcProvider: alg=none advertised and plain PKCE accepted by default
GHSA-86j7-9j95-vpqj - HIGH Better Auth has stored XSS in the auth-server origin via javascript: redirect_uri in oidc-provider and mcp
GHSA-cq3f-vc6p-68fh CVE-2026-45337 HIGH Better Auth: Device authorization approve and deny accept any authenticated session while the user code is pending
GHSA-p6v2-xcpg-h6xw CVE-2026-45364 HIGH Better Auth: Rate limiter keys IPv6 addresses individually and is bypassable via prefix rotation
GHSA-wxw3-q3m9-c3jr - MODERATE Better Auth: OAuth callback accepts mismatched `state` when cookie-backed state storage is used without PKCE
GHSA-wmjr-v86c-m9jj - LOW Better Auth's multi-session sign-out hook allows forged cookies to revoke arbitrary sessions
GHSA-xg6x-h9c9-2m83 - CRITICAL Better Auth Has Two-Factor Authentication Bypass via Premature Session Caching (session.cookieCache)
GHSA-x732-6j76-qmhm - HIGH Better Auth's rou3 Dependency has Double-Slash Path Normalization which can Bypass disabledPaths Config and Rate Limits
GHSA-vp58-j275-797x - HIGH Better Auth allows bypassing the trustedOrigins Protection which leads to ATO
GHSA-9x4v-xfq5-m8x5 - MODERATE Better Auth URL parameter HTML Injection (Reflected Cross-Site scripting)
GHSA-99h5-pjcv-gr6v CVE-2025-61928 HIGH Better Auth: Unauthenticated API key creation through api-key plugin
GHSA-36rg-gfq2-3h56 CVE-2025-53535 LOW Better Auth Open Redirect Vulnerability in originCheck Middleware Affects Multiple Routes
GHSA-hjpm-7mrm-26w8 CVE-2025-27143 MODERATE Beter Auth has an Open Redirect via Scheme-Less Callback Parameter
GHSA-8jhw-6pjj-8723 CVE-2024-56734 HIGH Better Auth has an Open Redirect Vulnerability in Verify Email Endpoint

CVE-2025-71401 at a Glance

CVE Identifier CVE-2025-71401
GHSA Identifier GHSA-569q-mpph-wgww
Severity HIGH
CVSS v3.1 Base Score N/A
CWE Classification CWE-770: Allocation of Resources Without Limits or Throttling
Affected Product Better auth
Package Ecosystem npm
Published Date
Last Updated

How to Fix CVE-2025-71401

To remediate this vulnerability, upgrade all affected Better auth dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

better-auth fixed: 1.4.2
npm install better-auth@1.4.2
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls better-auth

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2025-71401, inspect your project dependencies using npm:

npm ls better-auth

Analyze the terminal output to locate any version of Better auth in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.4.2), your application is affected.

Note: The npm ls better-auth command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-770: Allocation of Resources Without Limits or Throttling, where the product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated. In Better auth, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

# Summary Affected versions of Better Auth allow an external request to configure `baseURL` when it isn’t defined through any other means. This can be abused to poison the router’s base path, causing all routes to return 404 for all users. This issue is only exploitable when `baseURL` is not explicitly configured (e.g., `BETTER_AUTH_URL` is missing) *and* the attacker is able to make the very first request to the server after startup. In properly configured environments or typical managed hosting platforms, this fallback behavior cannot be reached. # Details A combination of `X-Forwarded-Host` and `X-Forwarded-Proto` is implicitly trusted. This allows the first request to configure baseURL whenever it is not explicitly configured. Here's the code that reads the headers: <img width="631" height="219" alt="headers" src="https://github.com/user-attachments/assets/b3fb0078-a62f-4058-9d0b-4afbd30c4953" /> Here's the call to `getBaseURL()`, the result is assigned to `ctx.baseURL`. <img width="838" height="414" alt="write" src="https://github.com/user-attachments/assets/a7b4dd17-75c3-49ef-9d08-6a2079d6a0ea" /> Here's the router receiving the poisoned `basePath`: <img width="594" height="372" alt="router" src="https://github.com/user-attachments/assets/5fdf2862-9cd1-4b96-b146-18e67d904157" /> `X-Forwarded-Host` and `X-Forwarded-Proto` can be used to modify the pathname of a parsed URL object which forms `baseURL`. `basePath` is then derived from the pathname of `baseURL`. Once the router `basePath` is poisoned it fails to match & route incoming requests. # Repro Start a better-auth server with no `baseURL` configuration. Send the following request as the first request to the server: ```curl curl -i --location 'https://example.com/api/auth/ok' \ --header 'X-Forwarded-Proto: some:' \ --header 'X-Forwarded-Host: junk' ``` The better-auth API check endpoint returns 404. Now send a regular request without the `X-Forwarded-Proto` and `X-Forwarded-Host` headers. ```curl curl -i --location 'https://example.com/api/auth/ok' ``` The better-auth API check endpoint still returns 404. _Example result_ <img width="662" height="307" alt="attack" src="https://github.com/user-attachments/assets/5a9cfdb5-3db7-4504-9f0a-b3c32a6dc823" /> We have modified the `basePath` for the router until the server is restarted. An attacker can repeatedly send these attack requests aiming to persistently exploit the vulnerability.

CVE-2025-71401 Affected Better auth Versions

1 component(s)
Fixed Versions:
1.4.2
Product / Package Ecosystem Affected Versions Fixed Version
better-auth
npm
< 1.4.2
1.4.2

References

Frequently Asked Questions

What is CVE-2025-71401?
CVE-2025-71401 is a security vulnerability in Better auth involving Better Auth affected by external request basePath modification DoS under CWE-770: Allocation of Resources Without Limits or Throttling.
Which Better auth versions are affected?
Affected versions include releases prior to 1.4.2 across affected packages: better-auth.
What version fixes CVE-2025-71401?
Upgrading to 1.4.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is better-auth affected?
Yes, better-auth is affected in releases prior to 1.4.2. Upgrade your dependency to 1.4.2 or later.
What CWE is associated with CVE-2025-71401?
CVE-2025-71401 is classified under CWE-770: Allocation of Resources Without Limits or Throttling (The product allocates a reusable resource or group of resources on behalf of an actor without imposing any intended restrictions on the size or number of resources that can be allocated.).
How can I check npm dependencies for CVE-2025-71401?
Run the dependency tree command: 'npm ls better-auth'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-569q-mpph-wgww",
  "modified" : "2026-09-01T18:56:11Z",
  "published" : "2025-12-01T21:29:48Z",
  "aliases" : [ "CVE-2025-71401" ],
  "summary" : "Better Auth affected by external request basePath modification DoS",
  "details" : "# Summary\n\nAffected versions of Better Auth allow an external request to configure `baseURL` when it isn’t defined through any other means. This can be abused to poison the router’s base path, causing all routes to return 404 for all users.\n\nThis issue is only exploitable when `baseURL` is not explicitly configured (e.g., `BETTER_AUTH_URL` is missing) *and* the attacker is able to make the very first request to the server after startup. In properly configured environments or typical managed hosting platforms, this fallback behavior cannot be reached.\n\n# Details\n\nA combination of `X-Forwarded-Host` and `X-Forwarded-Proto` is implicitly trusted. This allows the first request to configure baseURL whenever it is not explicitly configured.\n\nHere's the code that reads the headers:\n\n<img width=\"631\" height=\"219\" alt=\"headers\" src=\"https://github.com/user-attachments/assets/b3fb0078-a62f-4058-9d0b-4afbd30c4953\" />\n\nHere's the call to `getBaseURL()`, the result is assigned to `ctx.baseURL`.\n\n<img width=\"838\" height=\"414\" alt=\"write\" src=\"https://github.com/user-attachments/assets/a7b4dd17-75c3-49ef-9d08-6a2079d6a0ea\" />\n\nHere's the router receiving the poisoned `basePath`:\n\n<img width=\"594\" height=\"372\" alt=\"router\" src=\"https://github.com/user-attachments/assets/5fdf2862-9cd1-4b96-b146-18e67d904157\" />\n\n`X-Forwarded-Host` and `X-Forwarded-Proto` can be used to modify the pathname of a parsed URL object which forms `baseURL`. `basePath` is then derived from the pathname of `baseURL`. Once the router `basePath` is poisoned it fails to match & route incoming requests.\n\n# Repro\n\nStart a better-auth server with no `baseURL` configuration.\n\nSend the following request as the first request to the server:\n\n```curl\ncurl -i --location 'https://example.com/api/auth/ok' \\\n--header 'X-Forwarded-Proto: some:' \\\n--header 'X-Forwarded-Host: junk'\n```\n\nThe better-auth API check endpoint returns 404.\n\nNow send a regular request without the `X-Forwarded-Proto` and `X-Forwarded-Host` headers.\n\n```curl\ncurl -i --location 'https://example.com/api/auth/ok'\n```\n\nThe better-auth API check endpoint still returns 404.\n\n_Example result_\n\n<img width=\"662\" height=\"307\" alt=\"attack\" src=\"https://github.com/user-attachments/assets/5a9cfdb5-3db7-4504-9f0a-b3c32a6dc823\" />\n\nWe have modified the `basePath` for the router until the server is restarted. An attacker can repeatedly send these attack requests aiming to persistently exploit the vulnerability.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:P"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "better-auth"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.4.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/better-auth/better-auth/security/advisories/GHSA-569q-mpph-wgww"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-71401"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/ray-project/ray/commit/70e7c72780bdec075dba6cad1afe0832772bfe09"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/better-auth/better-auth"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/better-auth/better-auth/releases/tag/v1.4.2"
  }, {
    "type" : "WEB",
    "url" : "https://www.vulncheck.com/advisories/better-auth-before-basepath-modification-dos"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-73", "CWE-770" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2025-12-01T21:29:48Z",
    "nvd_published_at" : null
  }
}