Skip to content

Commit 9224427

Browse files
mcollinaaduh95
authored andcommitted
lib,test: redact proxy credentials in tunnel errors
Refs: https://hackerone.com/reports/3720313 Signed-off-by: Matteo Collina <hello@matteocollina.com> PR-URL: nodejs-private/node-private#867 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> CVE-ID: CVE-2026-48615
1 parent cb2aed9 commit 9224427

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

lib/internal/http.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function ipToInt(ip) {
9999
/**
100100
* Represents the proxy configuration for an agent. The built-in http and https agent
101101
* implementation have one of this when they are configured to use a proxy.
102-
* @property {string} href - Full URL of the proxy server.
102+
* @property {string} href - Proxy server URL with credentials redacted.
103103
* @property {string} protocol - Proxy protocol used to talk to the proxy server.
104104
* @property {string|undefined} auth - proxy-authorization header value, if username or password is provided.
105105
* @property {Array<string>} bypassList - List of hosts to bypass the proxy.
@@ -115,7 +115,13 @@ class ProxyConfig {
115115
}
116116
const { hostname, port, protocol, username, password } = parsedURL;
117117

118-
this.href = proxyUrl;
118+
if (username || password) {
119+
parsedURL.username = '';
120+
parsedURL.password = '';
121+
this.href = parsedURL.href;
122+
} else {
123+
this.href = proxyUrl;
124+
}
119125
this.protocol = protocol;
120126

121127
if (username || password) {

test/client-proxy/test-https-proxy-request-auth-failure.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ const { code, signal, stderr } = await runProxiedRequest({
5353
// The proxy client should get an error from proxy authentication failure.
5454
// Since the process exits cleanly but with an error, check for any error output
5555
assert.match(stderr, /407 Proxy Authentication Required/);
56+
assert.match(stderr, /via http:\/\/localhost:\d+\/?/);
57+
assert.doesNotMatch(stderr, /baduser/);
58+
assert.doesNotMatch(stderr, /badpass/);
5659
assert.strictEqual(code, 0);
5760
assert.strictEqual(signal, null);
5861

0 commit comments

Comments
 (0)