Security: Custom auth headers and proxy-authorization not stripped on cross-origin redirect · Issue #1880 · node-fetch/node-fetch · GitHub
Skip to content

Security: Custom auth headers and proxy-authorization not stripped on cross-origin redirect #1880

Description

@Den-Sec

Summary

node-fetch strips authorization, www-authenticate, cookie, and cookie2 on cross-origin redirect (src/index.js:200-213), but does NOT strip:

  1. proxy-authorization - Proxy credentials forwarded to redirect target
  2. Custom auth headers - X-API-Key, X-Auth-Token, etc. forwarded verbatim

Affected Code

src/index.js, lines 200-213:

if (!isDomainOrSubdomain(request.url, locationURL) || !isSameProtocol(request.url, locationURL)) {
    for (const name of ['authorization', 'www-authenticate', 'cookie', 'cookie2']) {
        requestOptions.headers.delete(name);
    }
}

Impact

Custom auth headers (extremely common in API usage) leak on cross-origin redirect. proxy-authorization also leaks.

Comparison

  • curl: Strips all credentials including custom headers unless --location-trusted
  • follow-redirects: Strips proxy-authorization (node-fetch does not)
  • Python requests: Same limitation for custom headers

Severity

CWE-200 | Medium

AI-assisted source code review, manually verified.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions