#4365·go-github

Auth transports add credentials after cross-origin redirects

Author: huynhtrungcscCreated Jul 4, 2026Updated Sep 18, 2026

Summary

BasicAuthTransport and UnauthenticatedRateLimitedTransport add credentials in RoundTrip for each outgoing request. When Go's net/http client follows a redirect to a different origin, the redirected request can pass through the same transport and receive those credentials again.

Expected behavior

Credentials added by these transports should only be sent to the original origin. Redirected requests that cross origin should continue without these transport-managed credentials.

Reproduction

This can be reproduced with two httptest servers: one server returns a redirect to a second server, and the second server records whether the redirected request contains the transport-added authorization headers.

Proposed fix

PR #4364 avoids adding these credentials on cross-origin redirect requests and includes regression coverage for both affected transports.