CVE-2022-21698: Uncontrolled Resource Consumption in promhttp
A denial of service attack was found in prometheus/clientgolang. This flaw allows an attacker to produce a denial of service attack on an HTTP server by exploiting the InstrumentHandlerCounter function in the version below 1.11.1, resulting in a loss of availability.
Other sources
A malicious actor can in theory kill / DOS a server in Go instrumented using prometheus/clientgolang InstrumentHandlerCounter in the version below 1.11.1.
InstrumentHandlerCounter function code: https://github.com/prometheus/clientgolang/blob/22da9497b8f0d53072dfc4721904faa7395d8318/prometheus/promhttp/instrumentserver.go#L95
Security advisory: https://github.com/prometheus/clientgolang/security/advisories/GHSA-cg3q-j54f-5p7p
Upstream fix: https://github.com/prometheus/clientgolang/commit/9075cdf61646b5adf54d3ba77a0e4f6c65cb4fd7 [main] https://github.com/prometheus/clientgolang/commit/989baa30fe956631907493ccee1f8e7708660d96 [release-1.11]
— Red Hat
clientgolang is the instrumentation library for Go applications in Prometheus, and the promhttp package in clientgolang provides tooling around HTTP servers and clients. In clientgolang prior to version 1.11.1, HTTP server is susceptible to a Denial of Service through unbounded cardinality, and potential memory exhaustion, when handling requests with non-standard HTTP methods. In order to be affected, an instrumented software must use any of promhttp.InstrumentHandler middleware except RequestsInFlight; not filter any specific methods (e.g GET) before middleware; pass metric with method label name to our middleware; and not have any firewall/LB/proxy that filters away requests with unknown method. clientgolang version 1.11.1 contains a patch for this issue. Several workarounds are available, including removing the method label name from counter/gauge used in the InstrumentHandler; turning off affected promhttp handlers; adding custom middleware before promhttp handler that will sanitize the request method given by Go http.Request; and using a reverse proxy or web application firewall, configured to only allow a limited set of methods.
This is the Go client library for Prometheus. It has two separate parts, one for instrumenting application code, and one for creating clients that talk to the Prometheus HTTP API. clientgolang is the instrumentation library for Go applications in Prometheus, and the promhttp package in clientgolang provides tooling around HTTP servers and clients.
Impact
HTTP server susceptible to a Denial of Service through unbounded cardinality, and potential memory exhaustion, when handling requests with non-standard HTTP methods.
Affected Configuration
In order to be affected, an instrumented software must
Use any of promhttp.InstrumentHandler middleware except RequestsInFlight. Do not filter any specific methods (e.g GET) before middleware. Pass metric with method label name to our middleware. Not have any firewall/LB/proxy that filters away requests with unknown method.
Patches
https://github.com/prometheus/clientgolang/pull/962 https://github.com/prometheus/clientgolang/pull/987
Workarounds
If you cannot upgrade to v1.11.1 or above, in order to stop being affected you can:
Remove method label name from counter/gauge you use in the InstrumentHandler. Turn off affected promhttp handlers. Add custom middleware before promhttp handler that will sanitize the request method given by Go http.Request. Use a reverse proxy or web application firewall, configured to only allow a limited set of methods.
For more information
If you have any questions or comments about this advisory:
Open an issue in https://github.com/prometheus/clientgolang Email us at prometheus-team@googlegroups.com
— GitHub
Uncontrolled Resource Consumption in promhttp
— Microsoft
Affected Software
Remediation
Patch Available
Patch Available
Event History
Parent advisories
This vulnerability appears in the following advisories.
- RHSA-2022:1461
- RHSA-2022:2216
- RHSA-2022:6430
- RHSA-2022:7261
- RHSA-2022:6290
- RHSA-2023:5314
- RHSA-2022:2218
- RHSA-2022:2217
- RHSA-2022:6040
- RHSA-2022:6042
- RHSA-2022:1762
- RHSA-2022:7519
- RHSA-2022:7529
- RHSA-2022:8057
- RHSA-2022:2280
- RHBA-2022:5876
- RHSA-2022:1356
- RHSA-2022:5068
- RHSA-2022:5069
- RHSA-2022:5070
- RHSA-2022:6537
- RHSA-2023:0566
- RHSA-2023:0652
- RHSA-2023:1158
- RHSA-2023:2014
- RHSA-2022:7399
- RHSA-2022:9096
- RHSA-2023:1326
- RHSA-2022:6156
- RHSA-2022:6066
- RHSA-2022:6061
- RHSA-2022:4667
- RHSA-2022:4668
- RHSA-2022:5026
- RHSA-2022:6526
- RHSA-2022:6051
Frequently Asked Questions
What is the vulnerability ID?
The vulnerability ID is CVE-2022-21698.
What is the severity of CVE-2022-21698?
The severity of CVE-2022-21698 is high, with a severity value of 7.5.
What is the affected software?
The affected software includes Prometheus Client Golang version up to 1.11.1, Fedoraproject Fedora versions 34-37, Fedoraproject Extra Packages For Enterprise Linux versions 7.0 and 8.0, and Rdo Project Rdo.
How does CVE-2022-21698 affect the Prometheus client library for Go?
CVE-2022-21698 is a denial of service attack vulnerability in the prometheus/client_golang library for Go applications.
How do I fix CVE-2022-21698?
To fix CVE-2022-21698, it is recommended to upgrade to a fixed version of Prometheus Client Golang or to apply the relevant security patches provided by the software vendor.