# GHSA-hq75-xg7r-rx6c: Better Call routing bug can lead to Cache Deception

> Insufficient path sanitization allows cache deception via CDN, exposing sensitive user session data to unauthorized users.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 11 Jul 2025

## What is GHSA-hq75-xg7r-rx6c?

GHSA-hq75-xg7r-rx6c is a vulnerability in better-call, published on 11 Jul 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### 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](https://github.com/Bekacru/better-call/blob/8b6f13e24fad7f4666a582601517bb3232d4f4af/src/router.ts#L124):
```js
	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:

<img width="800" alt="image" src="https://github.com/user-attachments/assets/2ab7c4dd-0700-4f59-863f-79f2b5edbb37" />

### Impact

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

## Which versions are affected by GHSA-hq75-xg7r-rx6c?

2 open source packages ship an affected version, including better-call.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `better-call` | npm | All versions | 1.0.12 |
| `better-call` | npm | All versions | 1.0.12 |

## How do I fix GHSA-hq75-xg7r-rx6c?

Upgrade better-call to 1.0.12 or later.

## Is GHSA-hq75-xg7r-rx6c being exploited?

There is no known exploitation of GHSA-hq75-xg7r-rx6c in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-hq75-xg7r-rx6c and fix it if it is affected.

What it is: GHSA-hq75-xg7r-rx6c is a vulnerability in better-call, published on 11 Jul 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-hq75-xg7r-rx6c in the wild and no public exploit code.

Affected packages and fixed versions:
- better-call (npm): affected all versions; fixed in 1.0.12
- better-call (npm): affected all versions; fixed in 1.0.12

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-hq75-xg7r-rx6c/ (Markdown: https://insights.sbomify.com/GHSA-hq75-xg7r-rx6c/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-hq75-xg7r-rx6c

---
From sbomify Insights: https://insights.sbomify.com/GHSA-hq75-xg7r-rx6c/
Summaries are generated and may contain mistakes; the official description above is the record.
