CVE-2025-71401: Better Auth affected by external request basePath modification DoS
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.
Published Dec 1, 2025 · Updated Sep 1, 2026
Affected packages
better-auth
- Ecosystem
- npm
- Affected
- < 1.4.2
- Fixed in
- 1.4.2
- Check
npm ls better-auth
Advisory details
From the GitHub Advisory Database (CC BY 4.0).
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:
Here's the call to getBaseURL(), the result is assigned to ctx.baseURL.
Here's the router receiving the poisoned basePath:
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 -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 -i --location 'https://example.com/api/auth/ok'The better-auth API check endpoint still returns 404.
_Example result_
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.
Credited to goksan, FROWNINGdev.
References
- https://github.com/better-auth/better-auth/security/advisories/GHSA-569q-mpph-wgww
- https://github.com/ray-project/ray/commit/70e7c72780bdec075dba6cad1afe0832772bfe09
- https://github.com/better-auth/better-auth/releases/tag/v1.4.2
- https://nvd.nist.gov/vuln/detail/CVE-2025-71401
- https://www.vulncheck.com/advisories/better-auth-before-basepath-modification-dos
- https://github.com/advisories/GHSA-569q-mpph-wgww
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. No analysis has been written for this entry yet. Methodology
More npm vulnerabilities
All npm entriesCVE-2026-114607
better-auth: OAuth state can be used as a Magic Link to sign in as another user
critical9.1Oct 27, 2026GHSA-44jh-23m7-hpcf
@better-auth/drizzle-adapter: Concurrent requests can exceed rate limits on PostgreSQL
low3.7Oct 27, 2026GHSA-q84f-53jg-9ppm
better-auth: Device login approval does not show the requesting client or permissions
high8.1Oct 27, 2026GHSA-r4xp-prcw-77qf
better-auth: OAuth Proxy lets an attacker sign in as another user
high7.4Oct 27, 2026GHSA-qq9h-g4jm-xgf3
Better Auth: Account takeover via pre-account hijacking on magic-link and email-OTP sign-in
high8.3Jul 24, 2026CVE-2026-53512
Better Auth: OAuth refresh-token replay via missing client authentication on oidc-provider and mcp plugins
critical9.1Jul 7, 2026
