# GHSA-7vwr-g6pm-9hc8: Cookie leakage between different users in fastapi-proxy-lib

> An attacker can steal session cookies from other users due to shared HTTP client state in the proxy library.

- **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:** 1 Dec 2023

## What is GHSA-7vwr-g6pm-9hc8?

GHSA-7vwr-g6pm-9hc8 is a vulnerability in fastapi-proxy-lib, published on 1 Dec 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact

In the implementation of version `0.0.1`, requests from different user clients are processed using a shared `httpx.AsyncClient`.

However, one oversight is that the `httpx.AsyncClient` will persistently store cookies based on the `set-cookie` response header sent by the target server and share these cookies across different user requests.

This results in a cookie leakage issue among all user clients sharing the same `httpx.AsyncClient`.

### Patches

It's fixed in `0.1.0`

### Workarounds

If you insist `0.0.1`:
- Do not use `ForwardHttpProxy` at all.
- Do not use `ReverseHttpProxy` or `ReverseWebSocketProxy` for any servers that may potentially send a `set-cookie` response.

**However, it's best to upgrade to the latest version.**

### References

fixed in [#10](https://github.com/WSH032/fastapi-proxy-lib/pull/10)

## Which versions are affected by GHSA-7vwr-g6pm-9hc8?

2 open source packages ship an affected version, including fastapi-proxy-lib.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `fastapi-proxy-lib` | PyPI | All versions | 0.1.0 |
| `fastapi-proxy-lib` | PyPI | All versions | 0.1.0 |

## How do I fix GHSA-7vwr-g6pm-9hc8?

Upgrade fastapi-proxy-lib to 0.1.0 or later.

## Is GHSA-7vwr-g6pm-9hc8 being exploited?

There is no known exploitation of GHSA-7vwr-g6pm-9hc8 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-7vwr-g6pm-9hc8 and fix it if it is affected.

What it is: GHSA-7vwr-g6pm-9hc8 is a vulnerability in fastapi-proxy-lib, published on 1 Dec 2023. 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-7vwr-g6pm-9hc8 in the wild and no public exploit code.

Affected packages and fixed versions:
- fastapi-proxy-lib (PyPI): affected all versions; fixed in 0.1.0
- fastapi-proxy-lib (PyPI): affected all versions; fixed in 0.1.0

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-7vwr-g6pm-9hc8/ (Markdown: https://insights.sbomify.com/GHSA-7vwr-g6pm-9hc8/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-7vwr-g6pm-9hc8

---
From sbomify Insights: https://insights.sbomify.com/GHSA-7vwr-g6pm-9hc8/
Summaries are generated and may contain mistakes; the official description above is the record.
