Skip to content

Commit 4d1c255

Browse files
thatnealpatelcagedmantis
authored andcommitted
net/http: strip sensitive proxy headers from redirect requests
Similarly to Authentication entries, Proxy-Authentication entries should be stripped to ensure sensitive information is not leaked on redirects outside of the original domain. https://fetch.spec.whatwg.org/#authentication-entries Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for reporting this issue. For #73816 Fixes CVE-2025-4673 Change-Id: Ied7b641f6531f1d340ccba3c636d3c30dd5547d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/679257 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent 3432c68 commit 4d1c255

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/net/http/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,8 @@ func (c *Client) makeHeadersCopier(ireq *Request) func(req *Request, stripSensit
806806
for k, vv := range ireqhdr {
807807
sensitive := false
808808
switch CanonicalHeaderKey(k) {
809-
case "Authorization", "Www-Authenticate", "Cookie", "Cookie2":
809+
case "Authorization", "Www-Authenticate", "Cookie", "Cookie2",
810+
"Proxy-Authorization", "Proxy-Authenticate":
810811
sensitive = true
811812
}
812813
if !(sensitive && stripSensitiveHeaders) {

src/net/http/client_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,8 @@ func testClientStripHeadersOnRepeatedRedirect(t *testing.T, mode testMode) {
15501550
if r.Host+r.URL.Path != "a.example.com/" {
15511551
if h := r.Header.Get("Authorization"); h != "" {
15521552
t.Errorf("on request to %v%v, Authorization=%q, want no header", r.Host, r.URL.Path, h)
1553+
} else if h := r.Header.Get("Proxy-Authorization"); h != "" {
1554+
t.Errorf("on request to %v%v, Proxy-Authorization=%q, want no header", r.Host, r.URL.Path, h)
15531555
}
15541556
}
15551557
// Follow a chain of redirects from a to b and back to a.
@@ -1578,6 +1580,7 @@ func testClientStripHeadersOnRepeatedRedirect(t *testing.T, mode testMode) {
15781580
req, _ := NewRequest("GET", proto+"://a.example.com/", nil)
15791581
req.Header.Add("Cookie", "foo=bar")
15801582
req.Header.Add("Authorization", "secretpassword")
1583+
req.Header.Add("Proxy-Authorization", "secretpassword")
15811584
res, err := c.Do(req)
15821585
if err != nil {
15831586
t.Fatal(err)

0 commit comments

Comments
 (0)