[Bug 1602813] [NEW] openvpn-auth-ldap causing segfault on network timeout

Launchpad Bug Tracker 1602813 at bugs.launchpad.net
Tue Jun 20 21:26:52 UTC 2017


You have been subscribed to a public bug by Andreas Hasenack (ahasenack):

[Impact]
There is a timeout bug in the openvpn-auth-ldap package that causes
OpenVPN to crash when the network timeout is exceeded.

The openvpn-auth-ldap plugin is not correctly checking the error codes
from ldap_result. As a result, it is not catching timeouts, and proceeds
as if ldap_result was successful. This results in a segfault when access
to the result (which is set to Null) is attempted.

Network timeouts are somewhat common and services should be resilient to
it. Having a service as a whole crash because of such an occurrence is
not acceptable.

This upload fixes the problem by simply including the timeout error case
in an existing check. It was clearly just an oversight in that one call,
as the remainder of the code does handle timeout errors. It was just
never reached.

[Test Case]
To reproduce the problem in an openvpn server:
* install openvpn and openvpn-auth-ldap:
$ sudo apt install openvpn openvpn-auth-ldap

* expand the attached openvpn-test-server.tar.gz tarball inside /etc:
$ sudo tar -C /etc -xzf openvpn-test-server.tar.gz

* start nc on port 389:
$ sudo nc -l -p 389

* In another terminal, start the openvpn server:
$ cd /etc/openvpn
$ sudo openvpn --config server.conf

Next you will need an openvpn client, also configured with the SSL certs
as usual, plus "auth-user-pass". This client can be the same for all server tests, if you are testing multiple Ubuntu releases, since what crashes is the server. It also doesn't have to be the fixed package from proposed.

* Install openvpn:
$ sudo apt install openvpn

* Expand the client tarball in /etc:
$ sudo tar -C /etc -xzf openvpn-test-client.tar.gz

* Edit /etc/openvpn/client.conf and change the "remote <hostname>" line
to point to your openvpn server's hostname

* Start the client:
$ cd /etc/openvpn
$ sudo openvpn --config client.conf

* It will prompt you for username and password. The values you provide are irrelevant:
(...)
Enter Auth Username: asd
Enter Auth Password: ***

The vulnerable server will crash:
root at trusty-openvpn-1602813:/etc/openvpn$ sudo openvpn --config server.conf
Tue Jun 20 13:56:55 2017 OpenVPN 2.3.2 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [eurephia] [MH] [IPv6] built on Dec  1 2014
Tue Jun 20 13:56:55 2017 TUN/TAP device tun0 opened
Tue Jun 20 13:56:55 2017 Note: Cannot set tx queue length on tun0: Operation not permitted (errno=1)
Tue Jun 20 13:56:55 2017 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Tue Jun 20 13:56:55 2017 /sbin/ip link set dev tun0 up mtu 1500
Tue Jun 20 13:56:55 2017 /sbin/ip addr add dev tun0 local 10.8.0.1 peer 10.8.0.2
Tue Jun 20 13:56:55 2017 UDPv4 link local (bound): [undef]
Tue Jun 20 13:56:55 2017 UDPv4 link remote: [undef]
Tue Jun 20 13:56:55 2017 Initialization Sequence Completed
openvpn: sasl.c:257: ldap_parse_sasl_bind_result: Assertion `res != ((void *)0)' failed.
Aborted (core dumped)

The fixed version will just complain about a timeout error and remain running:
(...)
LDAP bind failed: Timed out
Unable to bind as uid=john,ou=People,dc=lxd
LDAP connect failed.
Tue Jun 20 15:55:51 2017 10.0.100.162:1194 PLUGIN_CALL: plugin function PLUGIN_AUTH_USER_PASS_VERIFY failed with status 1: /usr/lib/openvpn/openvpn-auth-ldap.so
Tue Jun 20 15:55:51 2017 10.0.100.162:1194 TLS Auth Error: Auth Username/Password verification failed for peer
Tue Jun 20 15:55:51 2017 10.0.100.162:1194 [client] Peer Connection Initiated with [AF_INET]10.0.100.162:1194


[Regression Potential]
The patch is very focused. I believe the biggest regression potential lies in the fact that this package hasn't been rebuilt very often. This new build will be done with the surrounding system libraries having changed a lot since the last time this package was built.

[Other Info]
There are two places in the code which mishandled the return code of ldap_result(). They are essentially identical, but the test case I provided only covers one of them. I believe that to be good enough, as the other code path will require setting up an LDAP server with a populated directory.

** Affects: openvpn-auth-ldap (Ubuntu)
     Importance: Medium
     Assignee: Andreas Hasenack (ahasenack)
         Status: Fix Released

** Affects: openvpn-auth-ldap (Ubuntu Trusty)
     Importance: Medium
     Assignee: Andreas Hasenack (ahasenack)
         Status: In Progress

** Affects: openvpn-auth-ldap (Ubuntu Xenial)
     Importance: Medium
     Assignee: Andreas Hasenack (ahasenack)
         Status: In Progress

** Affects: openvpn-auth-ldap (Ubuntu Yakkety)
     Importance: Medium
     Assignee: Andreas Hasenack (ahasenack)
         Status: In Progress

** Affects: openvpn-auth-ldap (Ubuntu Zesty)
     Importance: Medium
     Assignee: Andreas Hasenack (ahasenack)
         Status: In Progress

** Affects: openvpn-auth-ldap (Debian)
     Importance: Unknown
         Status: New


** Tags: amd64 apport-crash bitesize ec2-images patch trusty
-- 
openvpn-auth-ldap causing segfault on network timeout
https://bugs.launchpad.net/bugs/1602813
You received this bug notification because you are a member of Ubuntu Sponsors Team, which is subscribed to the bug report.



More information about the Ubuntu-sponsors mailing list