CVE-2023-45142 OpenTelemetry-Go Contrib has DoS vulnerability in otelhttp due to unbound cardinality metrics

High 7.5 Published Updated

Attackers can cause memory exhaustion and denial of service by sending requests with unbounded User-Agent or HTTP method values to applications using the otelhttp handler.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2023-45142?

CVE-2023-45142 is a high-severity denial of service vulnerability in open-telemetry opentelemetry-go-contrib, published on 12 Oct 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official description

OpenTelemetry-Go Contrib is a collection of third-party packages for OpenTelemetry-Go. A handler wrapper out of the box adds labels `http.user_agent` and `http.method` that have unbound cardinality. It leads to the server's potential memory exhaustion when many malicious requests are sent to it. HTTP header User-Agent or HTTP method for requests can be easily set by an attacker to be random and long. The library internally uses `httpconv.ServerRequest` that records every value for HTTP `method` and `User-Agent`. In order to be affected, a program has to use the `otelhttp.NewHandler` wrapper and not filter any unknown HTTP methods or User agents on the level of CDN, LB, previous middleware, etc. Version 0.44.0 fixed this issue when the values collected for attribute `http.request.method` were changed to be restricted to a set of well-known values and other high cardinality attributes were removed. As a workaround to stop being affected, `otelhttp.WithFilter()` can be used, but it requires manual careful configuration to not log certain requests entirely. For convenience and safe usage of this library, it should by default mark with the label `unknown` non-standard HTTP methods and User agents to show that such requests were made but do not increase cardinality. In case someone wants to stay with the current behavior, library API should allow to enable it.

Weakness: CWE-770

Which versions are affected by CVE-2023-45142?

21 open source packages ship an affected version, including go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful, go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin and go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux. It affects 1 product.

PackageAffectedFixed in
go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin GoAll versions0.44.0
15 more packages
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp GoAll versions0.44.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp GoAll versions0.44.0
Linux distribution packages (2)
caddy openSUSE:TumbleweedAll versions2.7.6-1.1
golang-github-prometheus-prometheus openSUSE:TumbleweedAll versions2.53.0-3.1

Products include Opentelemetry Opentelemetry.

How do I fix CVE-2023-45142?

Upgrade go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful to 0.44.0 or later.

Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.

Is CVE-2023-45142 being exploited?

There is no known exploitation of CVE-2023-45142 in the wild and no public exploit code.

Sources

Also known as AZL-31303, AZL-33347, AZL-33516, AZL-34580, AZL-34889, AZL-34900 and 20 more.

Is CVE-2023-45142 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free