Summary
OpenTelemetry-Go Contrib vulnerable to denial of service in otelhttp due to unbound cardinality metrics
This handler wrapper https://github.com/open-telemetry/opentelemetry-go-contrib/blob/5f7e6ad5a49b45df45f61a1deb29d7f1158032df/instrumentation/net/http/otelhttp/handler.go#L63-L65
out of the box adds labels
http.user_agenthttp.method
that have unbound cardinality. It leads to the server's potential memory exhaustion when many malicious requests are sent to it.
Details
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.
PoC
Send many requests with long randomly generated HTTP methods or/and User agents (e.g. a million) and observe how memory consumption increases during it.
Others
It is similar to already reported vulnerabilities
- https://github.com/open-telemetry/opentelemetry-go-contrib/security/advisories/GHSA-5r5m-65gx-7vrh (open-telemetry/opentelemetry-go-contrib)
- https://github.com/advisories/GHSA-cg3q-j54f-5p7p (prometheus/client_golang)
Workaround for affected versions
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.
The other possibility is to disable HTTP metrics instrumentation by passing otelhttp.WithMeterProvider option with noop.NewMeterProvider.
Solution provided by upgrading
In PR https://github.com/open-telemetry/opentelemetry-go-contrib/pull/4277, released with package version 0.44.0, 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.
References
Impact
In order to be affected, the program has to configure a metrics pipeline, use otelhttp.NewHandler wrapper, and does not filter any unknown HTTP methods or User agents on the level of CDN, LB, previous middleware, etc.
The application allocates resources such as memory, threads, or file descriptors based on untrusted input without enforcing a cap. Typical impact: resource exhaustion leading to denial of service.
CVE-2023-45142 has a CVSS score of 7.5 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (0.44.0); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp to 0.44.0 or later; go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful to 0.44.0 or later; go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin to 0.44.0 or later; go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux to 0.44.0 or later; go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho to 0.44.0 or later; go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron to 0.44.0 or later; go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace to 0.44.0 or later
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2023-45142? CVE-2023-45142 is a high-severity allocation of resources without limits or throttling vulnerability in go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp (go), affecting versions < 0.44.0. It is fixed in 0.44.0. The application allocates resources such as memory, threads, or file descriptors based on untrusted input without enforcing a cap.
- How severe is CVE-2023-45142? CVE-2023-45142 has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which packages are affected by CVE-2023-45142?
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp(go) (versions < 0.44.0)go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestful(go) (versions < 0.44.0)go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin(go) (versions < 0.44.0)go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux(go) (versions < 0.44.0)go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho(go) (versions < 0.44.0)go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaron(go) (versions < 0.44.0)go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace(go) (versions < 0.44.0)
- Is there a fix for CVE-2023-45142? Yes. CVE-2023-45142 is fixed in 0.44.0. Upgrade to this version or later.
- Is CVE-2023-45142 exploitable, and should I be worried? Whether CVE-2023-45142 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2023-45142 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2023-45142?
- Upgrade
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttpto 0.44.0 or later - Upgrade
go.opentelemetry.io/contrib/instrumentation/github.com/emicklei/go-restful/otelrestfulto 0.44.0 or later - Upgrade
go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelginto 0.44.0 or later - Upgrade
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmuxto 0.44.0 or later - Upgrade
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelechoto 0.44.0 or later - Upgrade
go.opentelemetry.io/contrib/instrumentation/gopkg.in/macaron.v1/otelmacaronto 0.44.0 or later - Upgrade
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptraceto 0.44.0 or later
- Upgrade