openvpn-auth-ldap causing segfault on network timeout
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
openvpn-auth-ldap (Debian) |
Fix Released
|
Unknown
|
|||
openvpn-auth-ldap (Ubuntu) |
Fix Released
|
Medium
|
Andreas Hasenack | ||
Trusty |
Fix Released
|
Medium
|
Andreas Hasenack | ||
Xenial |
Fix Released
|
Medium
|
Andreas Hasenack | ||
Yakkety |
Won't Fix
|
Medium
|
Andreas Hasenack | ||
Zesty |
Fix Released
|
Medium
|
Andreas Hasenack |
Bug Description
[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-
$ sudo tar -C /etc -xzf openvpn-
* 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-
* Edit /etc/openvpn/
* 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@trusty-
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_
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_
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,
LDAP connect failed.
Tue Jun 20 15:55:51 2017 10.0.100.162:1194 PLUGIN_CALL: plugin function PLUGIN_
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]
[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.
tags: | removed: server-next |
Changed in openvpn-auth-ldap (Ubuntu): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
status: | Triaged → In Progress |
no longer affects: | openvpn (Ubuntu) |
Changed in openvpn-auth-ldap (Debian): | |
status: | Unknown → New |
Changed in openvpn-auth-ldap (Debian): | |
status: | Unknown → New |
Changed in openvpn-auth-ldap (Ubuntu): | |
importance: | High → Medium |
Changed in openvpn-auth-ldap (Ubuntu Trusty): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in openvpn-auth-ldap (Ubuntu Xenial): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in openvpn-auth-ldap (Ubuntu Yakkety): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in openvpn-auth-ldap (Ubuntu Zesty): | |
assignee: | nobody → Andreas Hasenack (ahasenack) |
Changed in openvpn-auth-ldap (Ubuntu Trusty): | |
status: | New → In Progress |
Changed in openvpn-auth-ldap (Ubuntu Xenial): | |
status: | New → In Progress |
Changed in openvpn-auth-ldap (Ubuntu Yakkety): | |
status: | New → In Progress |
Changed in openvpn-auth-ldap (Ubuntu Zesty): | |
status: | New → In Progress |
Changed in openvpn-auth-ldap (Ubuntu Trusty): | |
importance: | Undecided → Medium |
Changed in openvpn-auth-ldap (Ubuntu Xenial): | |
importance: | Undecided → Medium |
Changed in openvpn-auth-ldap (Ubuntu Yakkety): | |
importance: | Undecided → Medium |
Changed in openvpn-auth-ldap (Ubuntu Zesty): | |
importance: | Undecided → Medium |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
description: | updated |
Changed in openvpn-auth-ldap (Debian): | |
status: | New → Fix Released |
We have created this PPA to host a version of the package with the above patch added:
https:/ /launchpad. net/~foxpass/ +archive/ ubuntu/ openvpn- auth-ldap