From adc43f4b31dc78a0e4d6c6d035a19a841ee5c9ff Mon Sep 17 00:00:00 2001 From: CPANSec Security Scanner Bot Date: Tue, 24 Nov 2026 14:32:06 +0000 Subject: [PATCH] Net::Server::Proto::SSLEAY: apply SSL_verify_mode, CA and cipher options SSL_verify_mode, SSL_ca_file, SSL_ca_path and SSL_cipher_list were accepted as configuration and stored on the listening socket, but bind_SSL applied only the key and certificate. A server configured to require client certificates, using the same option names that proto ssl honours, accepted clients that presented none, and a restricted cipher list silently fell back to the OpenSSL default. Apply the options in bind_SSL with the corresponding Net::SSLeay calls: load SSL_ca_file and SSL_ca_path with CTX_load_verify_locations (or the OpenSSL default CA locations when a verify mode is set without them), set SSL_verify_mode with CTX_set_verify, and set SSL_cipher_list with CTX_set_cipher_list. A CA location or cipher list that cannot be applied stops the server at startup instead of being ignored. Document the newly supported parameters. Notes for deciding whether to apply this patch: - SSL_verify_mode, SSL_ca_file, SSL_ca_path and SSL_cipher_list now take effect. A server already configured with them starts verifying client certificates and restricting ciphers, so clients it used to accept may now be refused. - When a verify mode is set without SSL_ca_file or SSL_ca_path, the OpenSSL default CA locations are used, as IO::Socket::SSL does. - A CA location or cipher list that cannot be loaded now stops the server at startup. - SSL_passwd_cb and SSL_use_cert are still accepted and ignored. - Not tested on a running server. It was checked by review and by applying it to Net-Server 2.018. - Applies on its own to Net-Server 2.018, and together with the other CPANSec patches for Net-Server 2.018 when they are applied in CVE-ID order. --- lib/Net/Server/Proto/SSLEAY.pm | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/Net/Server/Proto/SSLEAY.pm b/lib/Net/Server/Proto/SSLEAY.pm index c395b6e..8278b41 100644 --- a/lib/Net/Server/Proto/SSLEAY.pm +++ b/lib/Net/Server/Proto/SSLEAY.pm @@ -154,6 +154,20 @@ sub bind_SSL { my $file_cert = $sock->SSL_cert_file || die "SSLeay missing SSL_cert_file on ".$sock->hup_string>".\n"; Net::SSLeay::CTX_use_RSAPrivateKey_file($ctx, $file_key, Net::SSLeay::FILETYPE_PEM()); $sock->SSLeay_check_fatal("SSLeay bind_SSL CTX_use_RSAPrivateKey_file"); Net::SSLeay::CTX_use_certificate_file( $ctx, $file_cert, Net::SSLeay::FILETYPE_PEM()); $sock->SSLeay_check_fatal("SSLeay bind_SSL CTX_use_certificate_file"); + + # Client certificate verification and cipher list, which were previously accepted but not applied + my $verify_mode = $sock->SSL_verify_mode; + my ($ca_file, $ca_path) = ($sock->SSL_ca_file, $sock->SSL_ca_path); + if (defined($ca_file) || defined($ca_path)) { + Net::SSLeay::CTX_load_verify_locations($ctx, $ca_file || '', $ca_path || '') or do { $sock->SSLeay_check_fatal("SSLeay bind_SSL CTX_load_verify_locations"); die "SSLeay could not load SSL_ca_file or SSL_ca_path on ".$sock->hup_string.".\n" }; + } elsif ($verify_mode) { + Net::SSLeay::CTX_set_default_verify_paths($ctx) or do { $sock->SSLeay_check_fatal("SSLeay bind_SSL CTX_set_default_verify_paths"); die "SSLeay could not load the default CA locations on ".$sock->hup_string.".\n" }; + } + Net::SSLeay::CTX_set_verify($ctx, $verify_mode) if $verify_mode; + if (defined(my $ciphers = $sock->SSL_cipher_list)) { + Net::SSLeay::CTX_set_cipher_list($ctx, $ciphers) or do { $sock->SSLeay_check_fatal("SSLeay bind_SSL CTX_set_cipher_list"); die "SSLeay could not set SSL_cipher_list on ".$sock->hup_string.".\n" }; + } + $sock->SSLeay_context($ctx); } @@ -579,6 +593,28 @@ be in PEM format. Full path to the key file to be used for this server. Should be in PEM format. +=item C + +Verification mode for client certificates, as passed to +Net::SSLeay::CTX_set_verify. The values are the same as for +IO::Socket::SSL, for example SSL_VERIFY_PEER (1), optionally combined +with SSL_VERIFY_FAIL_IF_NO_PEER_CERT (2) to reject clients that do not +present a certificate. Default is no verification. + +=item C + +=item C + +File, or directory, of trusted CA certificates in PEM format used to +verify client certificates. When SSL_verify_mode is set and neither +is given, the OpenSSL default CA locations are used. The server dies +at startup if they cannot be loaded. + +=item C + +OpenSSL cipher list string restricting the ciphers the server accepts. +The server dies at startup if the string is not accepted. + =item C Used during getline to only read until this many bytes are found. -- 2.53.0