# GHSA-4v48-4q5m-8vx4: Prometheus vulnerable to basic authentication bypass

> An attacker with access to hashed passwords can bypass basic authentication in Prometheus by poisoning the internal hash cache.

- **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:** 5 Dec 2022

## What is GHSA-4v48-4q5m-8vx4?

GHSA-4v48-4q5m-8vx4 is an authentication bypass vulnerability in github.com/prometheus/prometheus, published on 5 Dec 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact

Prometheus can be secured by a web.yml file that specifies usernames and hashed passwords for basic authentication.

Passwords are hashed with bcrypt, which means that even if you have access to the hash, it is very hard to find the original password back.

However, a flaw in the way this mechanism was implemented in the [exporter toolkit](https://github.com/prometheus/exporter-toolkit) makes it possible with people who know the hashed password to authenticate against Prometheus.

A request can be forged by an attacker to poison the internal cache used to cache the computation of hashes and make subsequent requests successful. This cache is used in both happy and unhappy scenarios in order to limit side channel attacks that could tell an attacker if a user is present in the file or not.

### Patches

Prometheus 2.37.4 ([LTS](https://prometheus.io/docs/introduction/release-cycle/)) and 2.40.4 have been released to address this issue.

### Workarounds

There is no workaround but attacker must have access to the hashed password, stored in disk, to bypass the authentication.

### Credit

We want to thank Lei Wan for reporting this security issue.

## Which versions are affected by GHSA-4v48-4q5m-8vx4?

8 open source packages ship an affected version, including github.com/prometheus/prometheus and github.com/prometheus/prometheus/v2.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/prometheus/prometheus` | Go | From 2.24.1 | 2.37.4 |
| `github.com/prometheus/prometheus` | Go | From 2.24.1 | 2.37.4 |
| `github.com/prometheus/prometheus` | Go | From 2.38.0 | 2.40.4 |
| `github.com/prometheus/prometheus` | Go | From 2.38.0 | 2.40.4 |
| `github.com/prometheus/prometheus/v2` | Go | From 2.24.1 | 2.37.4 |
| `github.com/prometheus/prometheus/v2` | Go | From 2.24.1 | 2.37.4 |
| `github.com/prometheus/prometheus/v2` | Go | From 2.38.0 | 2.40.4 |
| `github.com/prometheus/prometheus/v2` | Go | From 2.38.0 | 2.40.4 |

## How do I fix GHSA-4v48-4q5m-8vx4?

Upgrade github.com/prometheus/prometheus to a fixed version for your release line: 2.37.4 or 2.40.4.

## Is GHSA-4v48-4q5m-8vx4 being exploited?

There is no known exploitation of GHSA-4v48-4q5m-8vx4 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-4v48-4q5m-8vx4 and fix it if it is affected.

What it is: GHSA-4v48-4q5m-8vx4 is an authentication bypass vulnerability in github.com/prometheus/prometheus, published on 5 Dec 2022. 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-4v48-4q5m-8vx4 in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/prometheus/prometheus (Go): affected from 2.24.1; fixed in 2.37.4
- github.com/prometheus/prometheus (Go): affected from 2.24.1; fixed in 2.37.4
- github.com/prometheus/prometheus (Go): affected from 2.38.0; fixed in 2.40.4
- github.com/prometheus/prometheus (Go): affected from 2.38.0; fixed in 2.40.4
- github.com/prometheus/prometheus/v2 (Go): affected from 2.24.1; fixed in 2.37.4
- github.com/prometheus/prometheus/v2 (Go): affected from 2.24.1; fixed in 2.37.4
- github.com/prometheus/prometheus/v2 (Go): affected from 2.38.0; fixed in 2.40.4
- github.com/prometheus/prometheus/v2 (Go): affected from 2.38.0; fixed in 2.40.4

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-4v48-4q5m-8vx4/ (Markdown: https://insights.sbomify.com/GHSA-4v48-4q5m-8vx4/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-4v48-4q5m-8vx4

---
From sbomify Insights: https://insights.sbomify.com/GHSA-4v48-4q5m-8vx4/
Summaries are generated and may contain mistakes; the official description above is the record.
