Packages / better-call / Security

ModerateVulnerabilityGHSA-hq75-xg7r-rx6cPublished 11 Jul 2025

Better Call routing bug can lead to Cache Deception

Affected releases · better-call

  • 1.x1.0.0 – 1.0.11Fixed in 1.0.12
  • 0.3.x and older0.0.1 – 0.3.3No fix, no longer updated

On 1.x, the newest line:

npm install better-call@1.0.12
2.x
  1. Not affected

    2.0.0 – 2.0.6

    7 releases

1.x
  1. Affected

    1.0.0 – 1.0.11

    12 releases

  2. Fixed

    1.0.12 – 1.4.4

    45 releases, latest

0.x
  1. Affected

    0.0.1 – 0.3.3

    58 releases

122 stable releases of better-call, oldest to newest, one row per major.

Is your project affected?

Paste your package.json, or type the range you declare for better-call. It is read in your browser and sent nowhere.

What happens

Summary

Using a CDN that caches (/**/*.png, /**/*.json, /**/*.css, etc...) requests, a cache deception can emerge. This could lead to unauthorized access to user sessions and personal data when cached responses are served to other users.

Details

The vulnerability occurs in the request processing logic where path sanitization is insufficient. The library splits the path using config.basePath but doesn't properly validate the remaining path components. This allows specially crafted requests that appear to be static assets (like /api/auth/get-session/api/auth/image.png assuming config.basePath=/api/auth) to bypass typical CDN cache exclusion rules while actually returning sensitive data.

The problematic code here:

	const processRequest = async (request: Request) => {
		const url = new URL(request.url);
		const path = config?.basePath ? url.pathname.split(config.basePath)[1] : url.pathname;

Since this library is largely coupled with better-auth, it becomes more clear why this can be dangerous with an example request:

Impact

This is a cache deception vulnerability affecting better-call users with CDN caching enabled. which can expose sensitive data.