CVE-2021-36221: Vulnerability in golang package leads to net/http/httputil ReverseProxy Panic
Summary
CVE-2021-36221: Go before 1.15.15 and 1.16.x before 1.16.7 has a race condition that can lead to a net/http/httputil ReverseProxy panic upon an ErrAbortHandler abort. Affects golang across 2 version ranges.
< 1.15.15
>= 1.16.0, < 1.16.7
Fixed in 1.15.15 or 1.16.7, depending on the release line you run. How to fix ↓
Also tracked for
- stdlib · Go
- golang-1.15 · Debian:11
The same CVE-2021-36221 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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 golang package is a popular open-source programming language that provides a robust set of tools and libraries for building efficient and scalable applications. It is widely used for developing server-side applications, network services, and command-line tools. The package includes the net/http/httputil module, which offers utilities for HTTP server and client implementations. Unfortunately, a race condition in versions before 1.15.15 and 1.16.x before 1.16.7 can trigger a panic in the ReverseProxy component of net/http/httputil when an ErrAbortHandler abort occurs.
Vulnerability Detail
The vulnerability arises due to a race condition in the golang package's net/http/httputil ReverseProxy. This race condition can be exploited when an ErrAbortHandler abort happens, leading to a panic in the ReverseProxy module. The impact of this vulnerability can be severe, potentially causing unexpected crashes or instability in applications that utilize the affected package. It is important to note that this vulnerability only affects golang versions prior to 1.15.15 and 1.16.x before 1.16.7.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 1.15.151.15.15 -
>= 1.16.0, < 1.16.71.16.7
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
As a workaround, developers can consider implementing a custom error handling mechanism in their applications that can gracefully handle ErrAbortHandler aborts. By intercepting and handling these aborts, the race condition can be mitigated. Here is an example of how to implement a custom error handler in golang:
package main
import (
"fmt"
"net/http"
)
func main() {
proxy := &httputil.ReverseProxy{
Director: func(req *http.Request) {
req.URL.Scheme = "https"
req.URL.Host = "example.com"
},
ErrorHandler: func(rw http.ResponseWriter, req *http.Request, err error) {
// Custom error handling logic
fmt.Println("Error occurred: ", err)
// Additional error handling code
},
}
http.ListenAndServe(":8080", proxy)
}
Conclusion
In conclusion, the golang package versions prior to 1.15.15 and 1.16.x before 1.16.7 are vulnerable to a race condition in the net/http/httputil ReverseProxy module. This vulnerability can result in panics and instability in affected applications. It is crucial to update the golang package to the fixed versions and consider implementing custom error handling to mitigate the risk. For further assistance or support in resolving this vulnerability, please contact DevNack.com.
See every vulnerability recorded for golang →
FAQ
The vulnerability can lead to a panic in the net/http/httputil ReverseProxy module, potentially causing crashes or instability in applications that use the golang package.
Versions prior to 1.15.15 and 1.16.x before 1.16.7 are affected by this vulnerability.
To fix this vulnerability, update the golang package to version 1.15.15 or 1.16.7, depending on the version being used.
Yes, developers can implement a custom error handling mechanism to gracefully handle ErrAbortHandler aborts as a temporary workaround.
For more information about this vulnerability, refer to the CVE-2021-36221 entry or the official golang documentation.
Related vulnerabilities
Recent vulnerabilities recorded for golang.