CVE-2023-45289: Incorrect forwarding of sensitive headers and cookies on HTTP redirect in net/http
Summary
CVE-2023-45289: Incorrect forwarding of sensitive headers and cookies on HTTP redirect in net/http. Affects stdlib 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 · Bitnami
- golang-1.15 · Debian:11
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 impacted package is the Go standard library (stdlib) which provides a set of core packages for the Go programming language. The net/http package in the stdlib is responsible for handling HTTP requests and responses. It includes functionality for making HTTP requests, handling cookies, and managing headers. This vulnerability affects the behavior of the HTTP client when following redirects to domains that are not subdomain matches or exact matches of the initial domain.
Vulnerability Detail
The vulnerability arises from the incorrect forwarding of sensitive headers and cookies on HTTP redirects. When an HTTP redirect occurs to a domain that is not a subdomain match or exact match of the initial domain, the http.Client does not forward sensitive headers such as "Authorization" or "Cookie". This means that if a redirect goes from foo.com to www.foo.com, the Authorization header will be forwarded, but if the redirect goes to bar.com, the Authorization header will not be forwarded. An attacker could exploit this behavior by crafting a malicious HTTP redirect that causes sensitive headers to be unexpectedly forwarded. The impact of this vulnerability could include unauthorized access to protected resources or the exposure of sensitive information.
How To Fix
Latest published version: go1.25.5 as of 22 Oct 2026
go get stdlib@vgo1.25.5
Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.
If you can't move to the latest
The minimum fixed version depends on the release line you run.
-
< 1.21.81.21.8go get stdlib@v1.21.8 -
>= 1.22.0-0, < 1.22.11.22.1go get stdlib@v1.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
There is no specific workaround provided for this vulnerability. However, developers can manually handle the forwarding of sensitive headers and cookies by inspecting the redirect response and manually including the necessary headers in subsequent requests. Here is an example of how this can be done using the net/http package:
package main
import (
"fmt"
"net/http"
)
func main() {
client := &http.Client{}
req, err := http.NewRequest("GET", "http://example.com", nil)
if err != nil {
fmt.Println(err)
return
}
resp, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
if resp.StatusCode == http.StatusFound {
location := resp.Header.Get("Location")
if location != "" {
req, err = http.NewRequest("GET", location, nil)
if err != nil {
fmt.Println(err)
return
}
// Manually include sensitive headers in the new request
req.Header.Set("Authorization", resp.Request.Header.Get("Authorization"))
req.Header.Set("Cookie", resp.Request.Header.Get("Cookie"))
resp, err = client.Do(req)
if err != nil {
fmt.Println(err)
return
}
}
}
// Process the response
// ...
}
Conclusion
In conclusion, the Go standard library (stdlib) is vulnerable to incorrect forwarding of sensitive headers and cookies on HTTP redirects. This vulnerability can be mitigated by updating to the recommended versions of the Go standard library. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for stdlib →
FAQ
The impacted package is the Go standard library (stdlib).
The net/http package in the Go standard library is responsible for handling HTTP requests and responses.
The vulnerability is the incorrect forwarding of sensitive headers and cookies on HTTP redirects.
The potential ramifications include unauthorized access to protected resources and the exposure of sensitive information.
To fix this vulnerability, update the Go standard library to version 1.21.8 or later, or version 1.22.1 or later.
References
Related vulnerabilities
Recent vulnerabilities recorded for stdlib.