Bug 1090966

Summary: Net::LDAP should not set ciphers to 'ALL' if not requested explicitly
Product: Red Hat Enterprise Linux 6 Reporter: Petr Pisar <ppisar>
Component: perl-LDAPAssignee: Petr Pisar <ppisar>
Status: CLOSED ERRATA QA Contact: Stefan Kremen <skremen>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.5CC: antti, ddas, gabe.fahl, jaster, john.a.wagner, jplesnik, mnavrati, perl-maint-list, ppisar, psabata, skremen, tmraz
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: perl-LDAP-0.40-2.el6 Doc Type: Bug Fix
Doc Text:
When using the Net::LDAPS Perl module to connect to an LDAP server without specifying the list of allowed SSL ciphers, the SSL client offered and accepted all SSL ciphers, even those that were not enabled by default by the underlying cryptographic (OpenSSL) library. To fix this bug, the Net::LDAP source code and documentation have been modified not to request all ciphers by default. As a result, Perl LDAP clients use the default OpenSSL cipher list if not specified otherwise.
Story Points: ---
Clone Of: 1044401
: 1091316 (view as bug list) Environment:
Last Closed: 2015-12-15 16:37:30 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1002711, 1070830, 1075802, 1172231    
Attachments:
Description Flags
Fix ported to 0.40
none
Correction for the fix
none
Correction for the fix ported to 0.40 none

Description Petr Pisar 2014-04-24 13:31:33 UTC
+++ This bug was initially created as a clone of Bug #1044401 +++

Description of problem:
LDAPS connection fails with error: "IO::Socket::SSL: SSL connect attempt failed with unknown errorerror:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group"

Version-Release number of selected component (if applicable):
openssl-1.0.1e-15.el6.x86_64
openssl-1.0.1e-16.el6_5.x86_64

How reproducible:
#!/usr/bin/perl                                                                 

sub ldap_query {
        use Net::LDAPS;

        my $conn = Net::LDAPS->new('ldap.example.com',
                                 version => 3,
                                 port => 636,
                                 capath => '/etc/openldap/cacerts/',
                                 raw => qr/^$/
                               ) || die "$@\n";

        $conn->disconnect();
        return 0;
}

my $test = ldap_query();

Steps to Reproduce:
1. Run above script against suitable ldap-server
2.
3.

Actual results:
IO::Socket::SSL: SSL connect attempt failed with unknown errorerror:100AE081:elliptic curve routines:EC_GROUP_new_by_curve_name:unknown group

Expected results:
Empty output

Additional info:
Downgrade to openssl-1.0.0-27.el6_4.2.x86_64 solves the issue.

[...]
--- Additional comment from Tomas Mraz on 2014-04-24 09:03:10 GMT ---

Now when I finally got a readable packet dump I have to agree that the message the client is sending is incorrect. I really wonder though why the SSLv2 client hello message format is used as the default is set such that OpenSSL uses the SSLv3 client hello format.

Petr, does the perl layer set some non-default SSL cipher list string? The SSLv2 client hello is used because there are SSL2_.... ciphers in the cipher list although they are not supposed to be there unless explicitly configured so by user.

Nevertheless sending the ECC cipher suites in the SSLv2 client hello can be seen as openssl bug as well because there is no way to indicate the supported curve list in the SSLv2 client hello. So this report should be split to two bugs.

--- Additional comment from Petr Pisar on 2014-04-24 12:40:14 GMT ---

There many perl layers above OpenSSL, but the one which changes protocol version and cipher list from the OpenSSL default is Net::LDAP itself (package perl-LDAP).

Net::LDAP sets in case of implicit SSL (ldaps scheme):

  'SSL_version' => 'sslv2/3',
  'SSL_cipher_list' => 'ALL',

while in case of explicit SSL (STARTTLS inside LDAP protocol):

  'SSL_version' => 'tlsv1',
  'SSL_cipher_list' => 'ALL',

This test case is about the first case. And it can be reproduced with openssl(1) tool:

$ openssl s_client -connect 127.0.0.1:2000 -cipher ALL

Please note the current upstream perl-ldap still does that. Except the 'sslv2/3' spelling has been updated to 'sslv23'.

I guess there is no OpenSSL cipher list string for the-default-one, because the perl code looks like:

  SSL_cipher_list     => defined $arg->{ciphers} ? $arg->{ciphers} : 'ALL'

which is the reason why the default Net::LDAPS behavior is enabling all ciphers.

--- Additional comment from Tomas Mraz on 2014-04-24 12:55:23 GMT ---

The SSL_version setting is probably no problem. However the ALL cipher list string really should not be used. Either the cipher list should not be set at all or the 'DEFAULT' string could be used.
-----

I believe not setting SSL_cipher_list if ciphers argument not passed by Net::LDAPS application is the best option.

Comment 1 Petr Pisar 2014-04-24 14:40:58 UTC
Created attachment 889304 [details]
Fix ported to 0.40

This fix has been proposed to the perl-ldap upstream.

Comment 2 Petr Pisar 2014-04-25 07:08:43 UTC
How to test:

(1) Start an SSL server.
(2) Run a simple Net::LDAPS client without `ciphers' option against the server.
(3) Compare list of ciphers advertised by the client to the server against DEFAULT OpenSSL list (see `openssl ciphers DEFAULT' command output).
Before:
  The lists differ.
After:
  The lists are identical.

Comment 3 Petr Pisar 2014-06-02 05:32:43 UTC
Patch has been accepted by upstream into perl-ldap-0.63.

Comment 4 Petr Pisar 2014-08-06 08:47:51 UTC
Created attachment 924405 [details]
Correction for the fix

This fix for the original patch is needed. It removes superfluous `defined' keyword. It's upstream commit:

commit 0da06f89aeb715cbf241c2f70ddfc5c3ef4a63b7
Author: Peter Marschall <peter>
Date:   Tue Jun 17 19:32:28 2014 +0200

    LDAP.pm: set SSL_cipher_list to correct value
    
    Fix commit 11fe2a9 which contains a superfluous defined and thus
    set SSL_cipher_list to true instead of the value of the ciphers arg.
    
    Thanks to THOMAS GUEVIN <THOMAS.GUEVIN> for reporting the bug.

Comment 9 Petr Pisar 2015-11-19 09:24:14 UTC
Created attachment 1096568 [details]
Correction for the fix ported to 0.40

Comment 15 errata-xmlrpc 2015-12-15 16:37:30 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-2646.html