GitHub Advisoryadvisory · npm

GHSA-569q-mpph-wgww Better Auth affected by external request basePath modification DoS

HIGH Published 2025-12-01 Modified 2026-09-01 Official page ↗
Aliases
CVE-2025-71401
Ecosystem
npm
Packages
better-auth
Severity
High
CVSS vector
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
Weaknesses
CWE-73, CWE-770
Reviewed
2025-12-01

Affected packages

• npm better-auth: < 1.4.2 → fixed in 1.4.2

Description

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 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_ 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.

Related

Alias · CVE (1)

  • CVE-2025-71401 better-auth (npm) before 1.4.2 allows an external request to configure baseURL when it is not otherwise defined (e.g., BETTER_AUTH_URL is… vulnerability

Weakness · CWE (2)

  • CWE-73 External Control of File Name or Path weakness
  • CWE-770 Allocation of Resources Without Limits or Throttling weakness

References