Skip to content

tls.connect() aborts process on malformed ALPNProtocols instead of throwing an error #65069

Description

@brown-sussy

Version

v26.7.0

Platform

Darwin MacBook-Pro-2.local 25.0.0 Darwin Kernel Version 25.0.0: Tue Aug  5 22:46:55 PDT 2025; root:xnu-12377.1.6~5/RELEASE_ARM64_T6000 arm64
(bas

Subsystem

No response

What steps will reproduce the bug?

Run the following command:

node -e "require('node:tls').connect({ host: '127.0.0.1', port: 9999, ALPNProtocols: [''] })"

The process aborts with SIGABRT.

The same issue can be reproduced with malformed ALPN wire format buffers:

Buffer.from([0])
Buffer.from([2, 0x61])
Buffer.from([1, 0x61, 0x62])

passed as ALPNProtocols.

How often does it reproduce? Is there a required condition?

It reproduces consistently (100% of the time).

Required condition:

  • Node.js TLS client API is used through tls.connect();
  • ALPNProtocols contains an invalid ALPN protocol list;
  • The invalid input reaches the native TLS implementation.

No network interaction is required.

What is the expected behavior? Why is that the expected behavior?

The expected behavior is that Node.js rejects the invalid input by throwing a JavaScript exception (for example ERR_INVALID_ARG_VALUE) instead of terminating the process.

ALPNProtocols is a documented API option supporting string arrays and Buffer/Uint8Array inputs. Invalid values should be handled as invalid arguments and remain recoverable application errors.

What do you see instead?

The entire Node.js process aborts.

The failure occurs in TLSWrap::SetALPNProtocols():

CHECK_EQ(0, SSL_set_alpn_protos(ssl, protos.data(), protos.length()));

When OpenSSL rejects the malformed ALPN list, the CHECK assertion fails and Node exits with SIGABRT (exit code 134).

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions