Advisory

GHSA-h5gx-45rj-2h5j

Details, part 2 of 2. The advisory

Details

The negative control on the same bare client and same cross-host redirect shows the standard Authorization header is stripped by net/http, while the custom X-Kerberos-Hub-PrivateKey is forwarded — confirming the leak is specific to the custom-named auth header.

Suggested fix

Set a CheckRedirect policy on the client used in UploadKerberosHub (and the other Hub helpers in this file) that strips the X-Kerberos-Hub-PrivateKey / X-Kerberos-Hub-PublicKey headers (and any other custom auth headers) when the redirect target host differs from the original request host:

checkRedirect := func(req *http.Request, via []*http.Request) error {
	if len(via) > 0 && req.URL.Host != via[0].URL.Host {
		req.Header.Del("X-Kerberos-Hub-PrivateKey")
		req.Header.Del("X-Kerberos-Hub-PublicKey")
	}
	return nil
}
client = &http.Client{CheckRedirect: checkRedirect}

A regression test should assert that after a cross-host redirect the X-Kerberos-Hub-PrivateKey header is absent at the final host, and that same-host redirects still carry it.

Fix PR

A fix PR implementing the CheckRedirect strip plus a cross-host regression test is provided to the maintainer through the advisory's private temporary fork.

Credit

Reported by tonghuaroot.

Sources & licences