Conversation
When a request redirects to a different hostname, minipass-fetch already drops the authorization and cookie headers (npm#45) so credentials are not forwarded to the new host. The proxy-authorization header is in the same class but was left in place, so it survives onto the redirected request. Drop it alongside authorization and cookie, matching undici, follow-redirects (CVE-2024-28849), and @microsoft/kiota-http-fetchlibrary (CVE-2026-49336).
|
No review on this since June. It is a one-line change to credential handling, so rather than argue from the spec I compared what the two nearest implementations do, with file and line for each. The block on // lib/index.js:219
// if the redirect is to a new hostname, strip the authorization and cookie headers
if (parsedOriginal.hostname !== parsedRedirect.hostname) {
requestOpts.headers.delete('authorization')
requestOpts.headers.delete('cookie')
}Which header names each project removes when it strips: The two precedents disagree with each other, which is worth knowing. But this list is a strict subset of both, so whichever one you consider authoritative, something is missing. It matters because of who the header is for. A second gap, which this PR does not address. The condition compares hostnames only, while node-fetch also requires the same protocol: Row three is the one I would flag: a redirect from I have deliberately not touched either in this PR, because changing the condition is a policy decision about what counts as the same origin, while adding a name to the list is not. Happy to open a separate one for the protocol case if you want it, or to fold it in here if you would rather have one change. One thing I am not claiming: $ gh pr checks 196 --repo npm/minipass-fetch
no checks reported on the 'fix-strip-proxy-authorization-on-cross-host-redirect' branchNothing runs on this branch. The table above is a comparison of source I fetched from each project, not a live interception test; the existing Happy to rebase, or to take the one line directly and close this. No attribution needed. |
When a request is redirected to a different hostname, minipass-fetch already drops the
authorizationandcookieheaders so credentials are not forwarded to the new host (added in #45). Theproxy-authorizationheader is a credential header in the same class, but it is not dropped, so it stays on the redirected request and reaches the new host.This adds
proxy-authorizationto that same strip, right next toauthorizationandcookie. The redirect condition and everything else are unchanged.The other redirect-following clients already treat
proxy-authorizationas part of this boundary:authorization,cookie, andproxy-authorizationon a cross-origin redirect.Authorization,Proxy-Authorization, andCookieacross host/scheme changes (it addedProxy-Authorizationfor CVE-2024-28849).@microsoft/kiota-http-fetchlibraryaddedProxy-Authorizationto its cross-origin scrub recently (CVE-2026-49336).Scope: this is the same threat model as the existing
authorization/cookiestrip, that is, a caller that sets aProxy-Authorizationheader and then follows a redirect to a different host. It is defence in depth for parity with the clients above, not a new class of exploit.The existing "redirect to different host strips headers" test now also sends a
proxy-authorizationheader and asserts it is absent on the redirected request. Without the change the test fails, because the header reaches the new host.