Skip to content

fix: drop Proxy-Authorization header on cross-origin redirects (#1869) - #1871

Open
EnesKartal wants to merge 1 commit into
forwardemail:masterfrom
EnesKartal:fix-redirect-proxy-authorization
Open

EnesKartal wants to merge 1 commit into
forwardemail:masterfrom
EnesKartal:fix-redirect-proxy-authorization

Conversation

@EnesKartal

Copy link
Copy Markdown

Description

Fixes #1869.

When following cross-origin redirects, superagent cleans sensitive authentication headers (Authorization, Cookie). However, Proxy-Authorization was not stripped, allowing proxy credentials configured on the request to leak to unintended third-party redirect origins.

This PR ensures Proxy-Authorization is deleted when changesOrigin is true:

  • In src/utils.js: cleanHeader strips header['proxy-authorization'] when changesOrigin is true (covers 301, 302, 303).
  • In src/node/index.js: _redirect strips headers['proxy-authorization'] when changesOrigin is true (covers 307, 308).

Credentials continue to be preserved on same-origin redirects.

Verification

  • Added test cases in test/node/redirects-other-host.js ensuring:
    • Proxy-Authorization is stripped on 302, 307, and 308 cross-origin redirects.
    • Proxy-Authorization is preserved on same-origin redirects.
  • Full test suite passed (432 tests passing across HTTP/1 and HTTP/2).
  • Linting and build passed cleanly.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy-Authorization is forwarded to a different origin on redirect

1 participant