Skip to content

fix(proxy): do not set an IP-literal proxy as the TLS servername - #6148

Open
MIbtehajNasar wants to merge 1 commit into
nodejs:mainfrom
MIbtehajNasar:fix-6144-proxy-ip-servername
Open

MIbtehajNasar wants to merge 1 commit into
nodejs:mainfrom
MIbtehajNasar:fix-6144-proxy-ip-servername

Conversation

@MIbtehajNasar

Copy link
Copy Markdown
Contributor

This relates to...

Fixes #6144

Rationale

ProxyAgent pins the TLS servername (SNI) of the connection to the proxy to the proxy host, so the handshake is validated against the proxy rather than the (rewritten) target Host header. When the proxy is addressed by an IP literal (e.g. new ProxyAgent("https://127.0.0.1:8080")), this sets the SNI to an IP address.

SNI must be a hostname, never an IP (RFC 6066). Node 26 now enforces this and throws before the handshake:

ERR_INVALID_ARG_VALUE: The property 'options.servername' Setting the TLS ServerName to an IP address is not permitted.. Received '127.0.0.1'

So on Node 26 every request through an IP-addressed HTTPS proxy fails outright. Older Node silently sent the (invalid) IP SNI.

Changes

Derive the pinned proxy servername through util.getServerName(), which already returns '' for an IP address (and the hostname otherwise). An IP-addressed proxy is then connected to without SNI, while a hostname proxy is still pinned to its name. Applied to both the forward (non-tunnel) and tunnel code paths.

Features

N/A

Bug Fixes

Breaking Changes and Deprecations

N/A

Status

ProxyAgent pinned the TLS servername (SNI) of the connection to the proxy to
the proxy host. When the proxy is addressed by an IP literal this sets SNI to
an IP, which is invalid per RFC 6066; Node >= 26 rejects it outright with
ERR_INVALID_ARG_VALUE before the handshake, so every request through an
IP-addressed HTTPS proxy fails.

Derive the pinned servername through util.getServerName(), which returns ''
for an IP address. An IP-addressed proxy is then connected to without SNI,
while a hostname proxy is still pinned to its name. Applies to both the
forward (non-tunnel) and tunnel paths.

Fixes: nodejs#6144

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProxyAgent fails with IP-address HTTPS proxies on Node 26

1 participant