You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when cmd/go uses GOAUTH, it may add arbitrary custom headers (not just Authorization) to authenticate to a specific https:// URL prefix.
net/http copies request headers across redirect hops, and cmd/go currently preserves those copied headers.
if a request authenticates to host a and then redirects to a different host b, those GOAUTH-derived headers can be forwarded to b.
expected behavior:
when following a redirect to a different host, cmd/go should not forward GOAUTH-derived credential headers from the original host.
credentials should only be applied when they are derived for (or match) the destination URL prefix.
actual behavior:
after GOAUTH is applied (triggered by a prior 4xx), a subsequent 3xx redirect to a different host can result in the GOAUTH-derived header being sent to the redirect target host.
notes:
i understand from the private security triage discussion that this is not considered a security vulnerability. i am filing this as a behavior change / hardening request for cmd/go’s GOAUTH scoping model.
redirect preconditions are: unauthenticated 4xx (to trigger GOAUTH), then authenticated 3xx (redirect), then a redirect target on a different host.
repro sketch:
configure GOAUTH to return a custom header for https://a.test/ (example: X-Goauth-Token: secret).
make a request to https://a.test/ such that:
the first response is 401,
the second request includes the GOAUTH header,
the second response is a 302 redirect to https://b.test/.
observe that the request to https://b.test/ contains X-Goauth-Token.
proposed fix:
in cmd/go’s redirect handler, clear the copied header set on redirected requests and re-derive credentials based on the destination URL only.
add a regression test that proves a custom GOAUTH header is applied to a.test but not forwarded to b.test.
summary:
Authorization) to authenticate to a specifichttps://URL prefix.net/httpcopies request headers across redirect hops, and cmd/go currently preserves those copied headers.aand then redirects to a different hostb, those GOAUTH-derived headers can be forwarded tob.expected behavior:
actual behavior:
notes:
repro sketch:
GOAUTHto return a custom header forhttps://a.test/(example:X-Goauth-Token: secret).https://a.test/such that:401,302redirect tohttps://b.test/.https://b.test/containsX-Goauth-Token.proposed fix:
a.testbut not forwarded tob.test.callsite (observed):
src/cmd/go/internal/web/http.go(redirect policy)patch + test:
TestGOAUTHRedirectDoesNotForwardCustomHeaders(packagecmd/go/internal/web)