Sensitive Headers Not Forwarded in HTTP Redirect in golang
Summary
CVE-2023-45289: Incorrect forwarding of sensitive headers and cookies on HTTP redirect in net/http. Affects golang across 2 version ranges.
< 1.21.8
>= 1.22.0-0, < 1.22.1
Fixed in 1.21.8 or 1.22.1, depending on the release line you run. How to fix ↓
Also tracked for
- golang-1.15 · Debian:11
- stdlib · Go
The same CVE-2023-45289 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 scalable and efficient applications. It is widely used for developing server-side applications, network services, and command-line tools. However, a vulnerability has been identified in the golang package related to the handling of HTTP redirects.
Vulnerability Detail
The vulnerability in the golang package occurs when an HTTP redirect is followed to a domain that is not a subdomain match or exact match of the initial domain. In such cases, sensitive headers like "Authorization" or "Cookie" are not forwarded by the http.Client. This means that if a redirect leads to a different domain, the sensitive headers will not be included in the request, potentially exposing them to unauthorized access. This vulnerability could be exploited by an attacker through a maliciously crafted HTTP redirect, leading to unauthorized access to sensitive information.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
< 1.21.81.21.8 -
>= 1.22.0-0, < 1.22.11.22.1
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 temporary workaround, developers can manually include the sensitive headers in the redirected request. Here is an example of how to do this in Go:
// Create a new HTTP client
client := &http.Client{}
// Perform the initial request
resp, err := client.Get("http://example.com")
// Check if the response is a redirect
if resp.StatusCode == http.StatusMovedPermanently || resp.StatusCode == http.StatusFound {
// Create a new request with the redirected URL
req, err := http.NewRequest("GET", resp.Header.Get("Location"), nil)
if err != nil {
// Handle error
}
// Manually include the sensitive headers
req.Header.Set("Authorization", resp.Request.Header.Get("Authorization"))
req.Header.Set("Cookie", resp.Request.Header.Get("Cookie"))
// Perform the redirected request
resp, err = client.Do(req)
if err != nil {
// Handle error
}
}
// Process the response
// ...
Conclusion
In conclusion, the golang package is vulnerable to a security issue where sensitive headers are not forwarded in HTTP redirects to different domains. This could potentially lead to unauthorized access to sensitive information. It is recommended to update the golang package to version 1.22.1 or later to fix this vulnerability. A temporary workaround is available by manually including the sensitive headers in the redirected request. For further support on vulnerability remediation, you can contact DevNack.com.
See every vulnerability recorded for golang →
FAQ
The golang package is an open-source programming language that provides a set of tools and libraries for building applications.
This vulnerability could allow an attacker to access sensitive information by exploiting a maliciously crafted HTTP redirect.
To fix this vulnerability, update the golang package to version 1.22.1 or later.
Yes, a temporary workaround is to manually include the sensitive headers in the redirected request.
For more information about this vulnerability, you can refer to the vulnerability details provided by Bitnami at the following source: https://github.com/bitnami/vulndb/tree/main/data/golang/BIT-golang-2023-45289.json
References
Related vulnerabilities
Recent vulnerabilities recorded for golang.