tls: fix OpenSSL compression leak that breaks tests under ASAN

This is not impactful in any way - it's a fixed leak of the openssl
record compression descriptors, about 24 bytes leaked total, once
per process. Not meaningful.

It is annoying if you want to run with ASAN & leak detection though,
since it's an unambiguous leak we trigger every time crypto is used.

Signed-off-by: Tim Perry <pimterry@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/66600
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
Tim Perry authored and GitHub committed 2026-11-25 16:52:56 +00:00
1 parent 0623b0d4c7
commit 478c2eea87
2 files changed
+6 -3

No files matched your search

+4 -1
View File
@@ -526,7 +526,10 @@ void InitCryptoOnce() {
// Turn off compression. Saves memory and protects against CRIME attacks.
// No-op with OPENSSL_NO_COMP builds of OpenSSL.
sk_SSL_COMP_zero(SSL_COMP_get_compression_methods());
STACK_OF(SSL_COMP)* comp_methods = SSL_COMP_get_compression_methods();
while (sk_SSL_COMP_num(comp_methods) > 0) {
OPENSSL_free(sk_SSL_COMP_pop(comp_methods));
}
}
void GetFipsCrypto(const FunctionCallbackInfo<Value>& args) {
@@ -76,8 +76,8 @@ const fixtureCert = fixtures.readKey('agent1-cert.pem');
// Test: certificate compression must not enable record-level compression.
//
// RFC 8879 certificate compression is unrelated to TLS record compression
// (the CRIME attack vector). The latter is disabled by Node at startup via
// sk_SSL_COMP_zero, and by modern OpenSSL defaults as well. To confirm, we
// (the CRIME attack vector). The latter is disabled by Node at startup in
// InitCryptoOnce(), and by modern OpenSSL defaults as well. To confirm, we
// Verify a ClientHello sent by Node only advertises null record compression.
(async () => {
const { promise: clientHelloReceived, resolve: onClientHello } =