tls: wrap SNICallback invocation in try/catch
authorMatteo Collina <hello@matteocollina.com>
Tue, 17 Feb 2026 13:26:17 +0000 (14:26 +0100)
committerBastien Roucariès <rouca@debian.org>
Mon, 6 Apr 2026 14:18:52 +0000 (16:18 +0200)
commite8d8a25f11655cb2a38185be841fc09be569ca75
treee2794edc5637d681a91be10d4a866df5cc3ddf00
parente71906e5f437ee99b0a9b2a19c7c57b2d22084bb
tls: wrap SNICallback invocation in try/catch

Wrap the owner._SNICallback() invocation in loadSNI() with try/catch
to route exceptions through owner.destroy() instead of letting them
become uncaught exceptions. This completes the fix from CVE-2026-21637
which added try/catch protection to callALPNCallback,
onPskServerCallback, and onPskClientCallback but missed loadSNI().

Without this fix, a remote unauthenticated attacker can crash any
Node.js TLS server whose SNICallback may throw on unexpected input
by sending a single TLS ClientHello with a crafted server_name value.

Fixes: https://hackerone.com/reports/3556769
Refs: https://hackerone.com/reports/3473882
CVE-ID: CVE-2026-21637
PR-URL: https://github.com/nodejs-private/node-private/pull/839
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
CVE-ID: CVE-2026-21637

origin: https://github.com/nodejs/node/commit/cc3f294507c715908b2b31a5301e295b3de04152

Gbp-Pq: Name CVE-2026-21637_post1.patch
lib/_tls_wrap.js
test/parallel/test-tls-psk-alpn-callback-exception-handling.js