GHSA-cg3q-j54f-5p7p CVE-2022-21698 GO-2022-0322
Uncontrolled Resource Consumption in promhttp
- Severity
- 7.5 / 10
- High · CVSS 3.1
- Exploit chance (EPSS)
- 5.99%
- Chance of exploitation in the next 30 days. Higher than 93.32% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-400 Uncontrolled Resource Consumption
- CWE-772 Missing Release of Resource after Effective Lifetime
- Fix
1.11.1- Upgrade github.com/prometheus/client_golang to this version or later
Description
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. client_golang is the instrumentation library for Go applications in Prometheus, and the promhttp package in client_golang 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 exceptRequestsInFlight. - Do not filter any specific methods (e.g GET) before middleware.
- Pass metric with
methodlabel name to our middleware. - Not have any firewall/LB/proxy that filters away requests with unknown
method.
Patches
- https://github.com/prometheus/client_golang/pull/962
- https://github.com/prometheus/client_golang/pull/987
Workarounds
If you cannot upgrade to v1.11.1 or above, in order to stop being affected you can:
- Remove
methodlabel 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/client_golang
- Email us at
prometheus-team@googlegroups.com
Affected versions
Go
| Package | Vulnerable | Fixed in |
|---|---|---|
| github.com/prometheus/client_golang | < 1.11.1 |
1.11.1 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
github.com/prometheus/client_golang Go → 1.11.1
- go
go get github.com/prometheus/client_golang@v1.11.1 && go mod tidy
Severity breakdown
CVSS 3.1 7.5
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- None
- Integrity
- None
- Availability
- High
Weakness
CWE-400: Uncontrolled Resource Consumption
The product does not properly control the allocation and maintenance of a limited resource.
How to prevent it
- Architecture and Design: Design throttling mechanisms into the system architecture. The best protection is to limit the amount of resources that an unauthorized user can cause to be expended. A strong authentication and access control model will help prevent such attacks from occurring in the first place. The login application should be protected against DoS attacks as much as possible. Limiting the database access, perhaps by caching result sets, can help minimize the resources expended. To further limit the potential for a DoS attack, consider tracking the rate of requests received from users and blocking requests that exceed a defined rate threshold.
- Architecture and Design: Mitigation of resource exhaustion attacks requires that the target system either: recognizes the attack and denies that user further access for a given amount of time, or uniformly throttles all requests in order to make it more difficult to consume resources more quickly than they can again be freed. The first of these solutions is an issue in itself though, since it may allow attackers to prevent the use of the system by a particular valid user. If the attacker impersonates the valid user, they may be able to prevent the user from accessing the server in question. The second solution is simply difficult to effectively institute -- and even when properly done, it does not provide a full solution. It simply makes the attack require more resources on the part of the attacker.
- Architecture and Design: Ensure that protocols have specific limits of scale placed on them.
- Implementation: Ensure that all failures in resource allocation place the system into a safe posture.
CWE-772: Missing Release of Resource after Effective Lifetime
The product does not release a resource after its effective lifetime has ended, i.e., after the resource is no longer needed.
How to prevent it
- Requirements: Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid. For example, languages such as Java, Ruby, and Lisp perform automatic garbage collection that releases memory for objects that have been deallocated.
- Implementation: It is good practice to be responsible for freeing all resources you allocate and to be consistent with how and where you free resources in a function. If you allocate resources that you intend to free upon completion of the function, you must be sure to free the resources at all exit points for that function including error conditions.
- Operation, Architecture and Design: Use resource-limiting settings provided by the operating system or environment. For example, when managing system resources in POSIX, setrlimit() can be used to set limits for certain types of resources, and getrlimit() can determine how many resources are available. However, these functions are not available on all operating systems. When the current levels get close to the maximum that is defined for the application (see CWE-770), then limit the allocation of further resources to privileged users; alternately, begin releasing resources for less-privileged users. While this mitigation may protect the system from attack, it will not necessarily stop attackers from adversely impacting other users. Ensure that the application performs the appropriate error checks and error handling in case resources become unavailable (CWE-703).
References
Advisories
Packages
Other links
- github.com/prometheus/client_golang/security/advisories/GHSA-cg3q-j54f-5p7p
- github.com/prometheus/client_golang/pull/962
- github.com/prometheus/client_golang/pull/987
- pkg.go.dev/vuln/GO-2022-0322
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ZY2SL…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/ZKORF…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/SASRK…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/RN7JG…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/MH6AL…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/KBMVI…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/J5WPM…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/HLAQR…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/FY3N7…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/DLUJZ…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/AK7CJ…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/7V7I7…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/5OGNA…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/4KDET…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/3L6GD…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/36GUE…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/2PFW6…
- lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/2IK53…
- github.com/prometheus/client_golang/releases/tag/v1.11.1
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/2IK…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/2PF…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/36G…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/3L6…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/4KD…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/5OG…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/7V7…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/AK7…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/DLU…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/FY3…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/HLA…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/J5W…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/KBM…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/MH6…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/RN7…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/SAS…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ZKO…
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/ZY2…
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-rcjv-mgp8-qvmr OpenTelemetry-Go Contrib vulnerable to denial of service in otelhttp due to unbound cardinality metrics | High | Linked by the source |
| GHSA-5r5m-65gx-7vrh otelhttp and otelbeego have DoS vulnerability for high cardinality metrics | High | Linked by the source |
| GHSA-cggf-277g-3q54 pypdf has possible large memory usage when parsing page tree | High | Same weakness, CWE-400 |
| GHSA-3g3m-2fjr-6pw4 Glob: AbortSignal cancellation bypass allows post-timeout filesystem traversal | Medium | Same weakness, CWE-400 |
| GHSA-42gh-23hr-vphw pypdf has possible long runtimes when retrieving page labels | High | Same weakness, CWE-400 |
| GHSA-4vqv-7265-gm2w pypdf has possible large memory usage for exceptions in strict mode | High | Same weakness, CWE-400 |
| GHSA-62m5-6wh8-28x7 pypdf has possible long runtimes/large memory usage for encrypted PDF files | High | Same weakness, CWE-400 |
| GHSA-7wch-p9px-956x Forge: Regular expression denial of service in PEM decoding (pem.decode) | High | Same weakness, CWE-400 |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor