Skip to content

Commit 3b42cf7

Browse files
committed
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>
1 parent 6d5e309 commit 3b42cf7

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎src/crypto/crypto_util.cc‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,10 @@ void InitCryptoOnce() {
553553

554554
// Turn off compression. Saves memory and protects against CRIME attacks.
555555
// No-op with OPENSSL_NO_COMP builds of OpenSSL.
556-
sk_SSL_COMP_zero(SSL_COMP_get_compression_methods());
556+
STACK_OF(SSL_COMP)* comp_methods = SSL_COMP_get_compression_methods();
557+
while (sk_SSL_COMP_num(comp_methods) > 0) {
558+
OPENSSL_free(sk_SSL_COMP_pop(comp_methods));
559+
}
557560

558561
#ifndef OPENSSL_NO_ENGINE
559562
EnginePointer::initEnginesOnce();

‎test/parallel/test-tls-certificate-compression.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ const fixtureCert = fixtures.readKey('agent1-cert.pem');
7676
// Test: certificate compression must not enable record-level compression.
7777
//
7878
// RFC 8879 certificate compression is unrelated to TLS record compression
79-
// (the CRIME attack vector). The latter is disabled by Node at startup via
80-
// sk_SSL_COMP_zero, and by modern OpenSSL defaults as well. To confirm, we
79+
// (the CRIME attack vector). The latter is disabled by Node at startup in
80+
// InitCryptoOnce(), and by modern OpenSSL defaults as well. To confirm, we
8181
// Verify a ClientHello sent by Node only advertises null record compression.
8282
(async () => {
8383
const { promise: clientHelloReceived, resolve: onClientHello } =

0 commit comments

Comments
 (0)