follow-redirects: Cross-realm sensitiveHeaders arrays are discarded and custom credentials can follow redirects
Summary
follow-redirects 1.16.0 and 1.16.1 validate the documented sensitiveHeaders option using instanceof Array. An array created in another JavaScript realm is silently replaced with an empty list, allowing a caller-declared custom credential header to be forwarded to an attacker-controlled cross-origin redirect destination.
Details
Affected versions
The sensitiveHeaders option was introduced in 1.16.0. Published 1.16.0 and 1.16.1 both reproduced the issue, establishing a tested affected range of 1.16.0 through 1.16.1. The source checkout was pinned at revision 46301256333c90b7faac7aa126effe72ec16d16e; the exact npm 1.16.1 artifact reproduced independently.
Root cause
In index.js, options.sensitiveHeaders is reset when its local isArray() helper returns false. This helper checks value instanceof Array, which relies on realm identity. However, the same file already uses Array.isArray(options.headers), which properly recognizes arrays across different realms.
Suggested remediation
Use Array.isArray(value) for sensitiveHeaders, then validate and normalize each element as a header-name string. Implement same-realm and node:vm cross-realm tests for cross-origin redirects, including array-form header representations. Ensure that custom sensitive headers are stripped while unrelated headers remain untouched.
Duplicate review
While public advisory history includes other sensitive-header reports (such as array-form headers and regular-expression handling), repository searches revealed no prior report addressing cross-realm validation as of 2026-10-25. A private or differently phrased report may exist.
Proof of Concept
Set up two loopback HTTP servers where the first issues a 302 redirect to the second. Send X-API-Key and specify that name within sensitiveHeaders, comparing a standard array to a cross-realm array generated via:
const vm = require('node:vm');
const sensitiveHeaders = vm.runInNewContext(`['X-API-Key']`);
Observations against both source and the exact npm 1.16.1 package:
- Same-realm
['X-API-Key']: the redirect destination did not receive the header. - Cross-realm
['X-API-Key']:Array.isArray(value)evaluated totrue,value instanceof Arrayevaluated tofalse, and the redirect destination received theX-API-Keyheader. - An unrelated
X-Harmlessheader was preserved in both scenarios.
The complete 3.5 KB loopback-only test harness and raw JSON output are available privately.
Impact
Custom credential disclosure. Exploitation requires:
- A direct caller or wrapper that retains a cross-realm
sensitiveHeadersarray. - A custom credential specified in that option.
- An attacker-controlled or compromised endpoint returning a cross-origin redirect.
The demonstrated impact is the leakage of custom header values, potentially exposing an API key or service token until revoked.
Built-in protections for Authorization, Proxy-Authorization, and Cookie remain effective. Axios 1.20.0 using follow-redirects 1.16.1 did not reproduce the issue because Axios normalizes the array; this report does not claim Axios is affected. No third-party services were tested.
What to do
Upgrade follow-redirects to version 1.16.2 or later.
For custom implementations or patches, replace instanceof Array checks with Array.isArray(value) when validating sensitiveHeaders, normalize each member as a header-name string, and verify behavior with cross-realm tests.
Affected software
Click a technology to see all vulnerabilities affecting it.
| Platform | Package | Vulnerable versions | Fixed in |
|---|---|---|---|
| npm package | follow-redirects | >= 1.16.0, < 1.16.2 | 1.16.2 |
References
- https://github.com/follow-redirects/follow-redirects/security/advisories/GHSA-mrwp-f3q8-3g9p
- https://nvd.nist.gov/vuln/detail/CVE-2026-116689
- https://github.com/follow-redirects/follow-redirects/commit/b0a7751e9cd64cd8eeb6ec67d2f206a9cc88d3f8
- https://github.com/follow-redirects/follow-redirects
- https://github.com/follow-redirects/follow-redirects/releases/tag/v1.16.2
- CVSS vector
CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N- Weakness (CWE)
CWE-201- Platform
- npm
- Package
follow-redirects- Disclosed
- 30.10.2026
- Updated
- 08.11.2026 10:00
Sources and licenses · Edited or translated by DockRay; source rights and applicable licenses are retained.
OSV / GitHub Advisory Database - GHSA-mrwp-f3q8-3g9p - CC BY 4.0
Vulnerability history: follow-redirects
All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.
- Total entries
- 6
- First → latest
- 01.2022 10.2026
- Without a fix
- 0
- Exploited in attacks
- 0
Severity breakdown
- High 2
- Medium 4
Disclosures per year
- 2022: 2
- 2023: 0
- 2024: 2
- 2025: 0
- 2026: 2
-
follow-redirects: Cross-realm sensitiveHeaders arrays are discarded and custom credentials can follow redirects this entry
Know which vulnerabilities affect your application
With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.