From 9308084fcb388194dd35b525ce8b139206b56df7 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Sun, 10 May 2026 13:20:44 +0200 Subject: [PATCH] lib,test: redact proxy credentials in tunnel errors Refs: https://hackerone.com/reports/3720313 Signed-off-by: Matteo Collina PR-URL: https://github.com/nodejs-private/node-private/pull/867 Reviewed-By: Joyee Cheung CVE-ID: CVE-2026-48615 --- lib/internal/http.js | 10 ++++++++-- .../test-https-proxy-request-auth-failure.mjs | 3 +++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/internal/http.js b/lib/internal/http.js index 54f1121eb71..116d699f505 100644 --- a/lib/internal/http.js +++ b/lib/internal/http.js @@ -99,7 +99,7 @@ function ipToInt(ip) { /** * Represents the proxy configuration for an agent. The built-in http and https agent * implementation have one of this when they are configured to use a proxy. - * @property {string} href - Full URL of the proxy server. + * @property {string} href - Proxy server URL with credentials redacted. * @property {string} protocol - Proxy protocol used to talk to the proxy server. * @property {string|undefined} auth - proxy-authorization header value, if username or password is provided. * @property {Array} bypassList - List of hosts to bypass the proxy. @@ -115,7 +115,13 @@ class ProxyConfig { } const { hostname, port, protocol, username, password } = parsedURL; - this.href = proxyUrl; + if (username || password) { + parsedURL.username = ''; + parsedURL.password = ''; + this.href = parsedURL.href; + } else { + this.href = proxyUrl; + } this.protocol = protocol; if (username || password) { diff --git a/test/client-proxy/test-https-proxy-request-auth-failure.mjs b/test/client-proxy/test-https-proxy-request-auth-failure.mjs index ca0f82c97d8..0530ee03358 100644 --- a/test/client-proxy/test-https-proxy-request-auth-failure.mjs +++ b/test/client-proxy/test-https-proxy-request-auth-failure.mjs @@ -53,6 +53,9 @@ const { code, signal, stderr } = await runProxiedRequest({ // The proxy client should get an error from proxy authentication failure. // Since the process exits cleanly but with an error, check for any error output assert.match(stderr, /407 Proxy Authentication Required/); +assert.match(stderr, /via http:\/\/localhost:\d+\/?/); +assert.doesNotMatch(stderr, /baduser/); +assert.doesNotMatch(stderr, /badpass/); assert.strictEqual(code, 0); assert.strictEqual(signal, null);