CVE-2022-32148: Vulnerability in stdlib package - Improper exposure of client IP addresses in net/http/httputil: NewSingleHostReverseProxy
Summary
CVE-2022-32148: Improper exposure of client IP addresses in net/http before Go 1.17.12 and Go 1.18.4 can be triggered by calling httputil.ReverseProxy.ServeHTTP with a Request.Header map containing a nil value for the X-Forwarded-For he... Affects golang-1.15 versions < 1ed3c127daceaffb9aadc806ba60f0b51b47421b. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The stdlib package is a part of the Go programming language standard library. It provides a collection of commonly used functions and types that are essential for building Go applications. The net/http/httputil package within stdlib offers utilities for HTTP request/response handling, including the NewSingleHostReverseProxy function. This vulnerability affects versions 1.18.2 of the stdlib package.
Vulnerability Detail
The vulnerability, identified as CVE-2022-32148, arises from improper exposure of client IP addresses in the net/http package before Go 1.17.12 and Go 1.18.4. It can be triggered by calling the NewSingleHostReverseProxy function with a Request.Header map containing a nil value for the X-Forwarded-For header. This causes the ReverseProxy to set the client IP as the value of the X-Forwarded-For header. The exposure of client IP addresses can lead to potential security risks, such as IP address spoofing and unauthorized access.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a workaround, developers can manually modify the Request.Header map to ensure that the X-Forwarded-For header is not set to a nil value before calling the NewSingleHostReverseProxy function. Here is an example code snippet:
req.Header.Del("X-Forwarded-For")
Conclusion
In conclusion, the stdlib package in Go versions before 1.17.12 and 1.18.4 is vulnerable to improper exposure of client IP addresses. This can lead to security risks such as IP address spoofing and unauthorized access. It is recommended to update the stdlib package to the fixed versions or apply the provided workaround. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for golang-1.15 →
FAQ
The vulnerability exposes client IP addresses, which can be exploited for IP address spoofing and unauthorized access.
Versions before Go 1.17.12 and Go 1.18.4 are affected by this vulnerability.
You can use the Vulert Playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Simply upload your manifest file (e.g., package-lock.json) and Vulert will provide real-time alerts for open-source vulnerabilities in your software.
There are no known exploits for this vulnerability at the time of this report. However, it is crucial to apply the recommended fixes to mitigate potential risks.
You can find more information about this vulnerability in the National Vulnerability Database (NVD) entry: https://nvd.nist.gov/vuln/detail/CVE-2022-32148
Related vulnerabilities
Recent vulnerabilities recorded for golang-1.15.