Skip to content

net,tls: fix session reuse with provided sockets - #64430

Open
harjothkhara wants to merge 1 commit into
nodejs:mainfrom
harjothkhara:codex/fix-tls-wrapped-session-reuse
Open

harjothkhara wants to merge 1 commit into
nodejs:mainfrom
harjothkhara:codex/fix-tls-wrapped-session-reuse

Conversation

@harjothkhara

@harjothkhara harjothkhara commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes: #64402

TLS sessions are bound to the authenticated server identity. When
tls.connect() wrapped a net.Socket connected to a literal IP address,
the socket did not retain its requested host and the TLS layer could fall
back to localhost. The offered session was then rejected because its
stored identity did not match. This surfaced after the host-binding
hardening in 9cc4e32375 (CVE-2026-48934).

Preserve the requested host for literal-IP socket connections before the
connection begins.
Add TLS 1.2 and TLS 1.3 regression coverage for both already-connected and
still-connecting provided sockets. Also verify that a session captured for
one literal-IP peer is rejected for another peer, hostname-based reuse stays
intact, and explicit servername continues to take precedence. The host is
recorded before both the literal-IP and DNS/autoSelectFamily branches.

Note: the same identity chain also feeds checkServerIdentity, so
certificate verification for wrapped literal-IP sockets now checks the
actual IP address instead of the historical localhost fallback,
matching what a direct tls.connect({ host }) connection already does.

Tests:

  • python3 tools/test.py --mode=release parallel/test-tls-session-reuse-provided-socket parallel/test-tls-session-reuse-different-servername parallel/test-tls-secure-session parallel/test-https-agent-session-reuse parallel/test-net-connect-options-fd
  • make lint

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/net

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem. labels Jul 11, 2026
@harjothkhara
harjothkhara marked this pull request as ready for review July 12, 2026 21:24
@harjothkhara

Copy link
Copy Markdown
Contributor Author

Could someone from @nodejs/net start CI and take a look? This fixes #64402.

@harjothkhara

harjothkhara commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

@lpinca @pimterry @jasnell follow-up: this fixes #64402, includes a regression test, and has had no review or CI run since July 11. Could someone take a look and start CI?

@MikeMcC399

MikeMcC399 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

You requested a review in Slack and I notice that the PR branch is out of date, and there is no record of a full GitHub Actions CI run occurring.

Hopefully one of the network team will be able to respond to your request for review.

In the meantime, I would suggest that you rebase the branch in this PR according to the Pull requests documentation. That should cause an automatic CI run in GitHub Actions.

Preserve literal IP hosts on net.Socket before connection. This keeps
wrapped TLS sessions bound to the correct peer when tls.connect() uses a
provided socket.

Fixes: nodejs#64402
Signed-off-by: harjoth <harjoth.khara@gmail.com>
Assisted-by: Codex
@harjothkhara
harjothkhara force-pushed the codex/fix-tls-wrapped-session-reuse branch from 47d1502 to 4592e0f Compare October 15, 2026 19:07
@harjothkhara

Copy link
Copy Markdown
Contributor Author

Thanks @MikeMcC399, rebased on main. GitHub Actions CI is running now.

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

Labels

needs-ci PRs that need a full CI run. net Issues and PRs related to the net subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tls.connect() ignores the session option when socket is provided (regression v22.22.3 → v22.23.1)

3 participants