# CVE-2026-40179: Prometheus has Stored XSS via metric names and label values in Prometheus web UI tooltips and metrics explorer

Source: https://junglewise.ai/threats/cve-2026-40179-prometheus-has-stored-xss-via-metric-names-and-label-values-in  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-13. Updated: 2026-05-11  
License: CC BY 4.0 with a link back

CVE-2026-40179 · Severity: medium · CVSS 6.1 · Published 2026-04-13

### Impact

Stored cross-site scripting (XSS) via crafted metric names in the Prometheus web UI:

* **Old React UI + New Mantine UI:** When a user hovers over a chart tooltip on the Graph page, metric names containing HTML/JavaScript are injected into `innerHTML` without escaping, causing arbitrary script execution in the user's browser.
* **Old React UI only:** When a user opens the Metric Explorer (globe icon next to the PromQL expression input field), and a metric name containing HTML/JavaScript is rendered in the fuzzy search results, it is injected into `innerHTML` without escaping, causing arbitrary script execution in the user's browser.
* **Old React UI only:** When a user views a heatmap chart and hovers over a cell, the `le` label values of the underlying histogram buckets are interpolated into `innerHTML` without escaping. While `le` is conventionally a numeric bucket boundary, Prometheus does not enforce this — arbitrary UTF-8 strings are accepted as label values, allowing script injection via a crafted scrape target or remote write.

With Prometheus v3.x defaulting to UTF-8 metric and label name validation, characters like `<`, `>`, and `"` are now valid in metric names and labels, making this exploitable.

An attacker who can inject metrics (via a compromised scrape target, remote write, or OTLP receiver endpoint) can execute JavaScript in the browser of any Prometheus user who views the metric in the Graph UI. From the XSS context, an attacker could for example:

- Read `/api/v1/status/config` to extract sensitive configuration (although credentials / secrets are redacted by the server)
- Call `/-/quit` to shut down Prometheus (only if `--web.enable-lifecycle` is set)
- Call `/api/v1/admin/tsdb/delete_series` to delete data (only if `--web.enable-admin-api` is set)
- Exfiltrate metric data to an external server

Both the new Mantine UI and the old React UI are affected. The vulnerable code paths are:

- `web/ui/mantine-ui/src/pages/query/uPlotChartHelpers.ts` — tooltip `innerHTML` with unescaped `labels.__name__`
- `web/ui/react-app/src/pages/graph/GraphHelpers.ts` — tooltip content with unescaped `labels.__name__`
- `web/ui/react-app/src/pages/graph/MetricsExplorer.tsx` — fuzzy search results rendered via `dangerouslySetInnerHTML` without sanitization
- `web/ui/react-app/src/vendor/flot/jquery.flot.heatmap.js` — heatmap tooltip with unescaped label values

### Patches

A patch has been published in Prometheus 3.5.2 LTS and Prometheus 3.11.2. The fix applies `escapeHTML()` to all user-controlled values (metric names and label values) before inserting them into `innerHTML`. This advisory will be updated with the patched version once released.

### Workarounds

- If using the remote write receiver (`--web.enable-remote-write-receiver`), ensure it is not exposed to untrusted sources.
- If using the OTLP receiver (`--web.enable-otlp-receiver`), ensure it is not exposed to untrusted sources.
- Ensure scrape targets are trusted and not under attacker control.
- Do not enable admin / mutating API endpoints (e.g. `--web.enable-admin-api` or `web.enable-lifecycle`) in cases where you cannot prevent untrusted data from being ingested.
- Users should avoid clicking untrusted links, especially those containing functions such as label_replace, as they may generate poisoned label names and values.

### Acknowledgements

Thanks to @gladiator9797 (Duc Anh Nguyen from TinyxLab) for reporting this.

Technologies: [github.com/prometheus/prometheus (Go)](https://junglewise.ai/threats/technologies/github-com-prometheus-prometheus). Vendors: [Go](https://junglewise.ai/threats/vendors/go).

## Quick answers

**Is CVE-2026-40179 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-40179 being exploited in the wild.

**How severe is CVE-2026-40179?** Medium severity, with a CVSS score of 6.1, published 13 April 2026.

**Which products and versions are affected?** github.com/prometheus/prometheus (Go) SEMVER:introduced=0,fixed=0.311.2-0.20260410083055-07c6232d159b, SEMVER:introduced=3.0.0,fixed=3.5.2.

**Is there a fix for CVE-2026-40179?** Yes. github.com/prometheus/prometheus (Go): upgrade to 0.311.2-0.20260410083055-07c6232d159b, 3.5.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**Am I affected by CVE-2026-40179?** Check whether you run github.com/prometheus/prometheus (Go) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- github.com/prometheus/prometheus (Go): upgrade to 0.311.2-0.20260410083055-07c6232d159b, 3.5.2 or later

  ```sh
  go get github.com/prometheus/prometheus@v3.5.2
  ```


## Affected products

- github.com/prometheus/prometheus (Go) SEMVER:introduced=0,fixed=0.311.2-0.20260410083055-07c6232d159b, SEMVER:introduced=3.0.0,fixed=3.5.2

## Identifiers

- CVE-2026-40179
- GHSA-vffh-x6r8-xx99
- GO-2026-5662

## References

- [https://api.github.com/users/gladiator9797](https://api.github.com/users/gladiator9797)
- [https://github.com/gladiator9797](https://github.com/gladiator9797)
- [https://api.github.com/users/gladiator9797/gists%7B/gist_id%7D](https://api.github.com/users/gladiator9797/gists%7B/gist_id%7D)
- [https://api.github.com/users/gladiator9797/repos](https://api.github.com/users/gladiator9797/repos)
- [https://avatars.githubusercontent.com/u/38899223?v=4](https://avatars.githubusercontent.com/u/38899223?v=4)
- [https://api.github.com/users/gladiator9797/events%7B/privacy%7D](https://api.github.com/users/gladiator9797/events%7B/privacy%7D)

## Related threats

- [Prometheus stored XSS in legacy web UI heatmap chart](https://junglewise.ai/threats/cve-2026-44903-prometheus-stored-xss-in-legacy-web-ui-heatmap-chart)
- [Prometheus denial of service via memory exhaustion in remote read endpoint](https://junglewise.ai/threats/cve-2026-42154-prometheus-denial-of-service-via-memory-exhaustion-in-remote-read)
- [Prometheus information disclosure in Azure AD OAuth configuration](https://junglewise.ai/threats/cve-2026-42151-prometheus-information-disclosure-in-azure-ad-oauth-configuration)
- [Withdrawn Advisory: Prometheus XSS Vulnerability](https://junglewise.ai/threats/cve-2019-3826-withdrawn-advisory-prometheus-xss-vulnerability)
- [Arbitrary redirects under /new endpoint](https://junglewise.ai/threats/cve-2021-29622-arbitrary-redirects-under-new-endpoint)
