Summary
A redirect-handling flaw in the Node.js urllib HTTP client can carry caller-supplied authentication and sensitive headers from one origin to a different redirect target. If an application follows redirects to an untrusted or unintended scheme, host, or port, credentials may be disclosed and potentially reused by another service.
Affected context
The vulnerability occurs in urllib deployments that enable redirect following while retaining request options across redirect destinations. It becomes risky when a redirect crosses an origin boundary and the original request includes authorization headers, cookies, proxy credentials, API keys, authentication tokens, or digest authentication values. The exposure depends on the application's redirect policy and the trustworthiness of redirect targets.
Exploit preconditions
- Attack surface: HTTP requests made through urllib with redirect following enabled
- Required access: Ability to cause or influence a requested resource to return a redirect, or control a reachable redirect destination
- Trigger point: Processing a redirect to a different scheme, host, or port
- Why exploitation is possible: Caller-supplied headers and authentication options are reused for the redirected request without sufficient origin-boundary filtering
Why this happens
The underlying bug is improper preservation of sensitive request state across origin changes. The redirect implementation recursively reuses the original request options, allowing credentials and security-sensitive headers to accompany a request sent to a different destination. This maps primarily to CWE-200, Exposure of Sensitive Information to an Unauthorized Actor, and is also related to CWE-201 and CWE-522 because transmitted credentials and authentication data are not adequately constrained to their intended origin.
Potential impact
- An attacker could receive authorization headers, cookies, API keys, or access tokens.
- Exposed credentials could be replayed against the original partner API or related services.
- Proxy authentication data could be disclosed to an unintended endpoint.
- A compromised token could enable unauthorized access, data retrieval, or account actions.
- Sensitive request metadata could be exposed across network or service boundaries.
General mitigation guidance
Mitigation generally focuses on treating redirects as security-sensitive
origin transitions rather than transparent continuation requests.
Common defensive patterns include:
- Strip authorization, cookie, proxy-authorization, API-key, and token headers when a redirect changes scheme, host, or port.
- Rebuild authentication state only after independently validating the destination and its trust relationship.
- Prefer redirect policies that allow only explicitly trusted origins and schemes.
- Avoid sending bearer credentials or long-lived secrets to destinations selected from untrusted input.
- Use narrowly scoped, short-lived credentials with least privilege.
- Preserve sensitive headers only when the destination remains within a validated origin boundary.
How teams detect issues like this
Organizations can identify related issues through:
- Static analysis searches for redirect handlers that reuse mutable request options or headers.
- Code review checks for credential propagation across scheme, host, or port changes.
- Tests that verify sensitive headers are removed during cross-origin redirects.
- Runtime logging and policy enforcement for redirect destinations, without recording credential values.
- Dependency and software composition analysis for HTTP clients with known redirect-handling weaknesses.

