M-053: mod_ssl and Apache_SSL Modules Contain a Buffer Overflow Privacy and Legal Notice

CIAC INFORMATION BULLETIN

M-053: mod_ssl and Apache_SSL Modules Contain a Buffer Overflow

[CERT Vulnerability Note VU#234971]

March 6, 2002 00:00 GMT

PROBLEM: There is a remotely exploitable buffer overflow in two modules that implement the Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocol.
PLATFORM: mod_ssl in all versions prior to 2.8.7-1.3.23.
Apache-SSL in all version prior to 1.3.22+1.4.6.
DAMAGE: An attacker may be able to execute arbitrary code on the system with the privileges of the ssl module.
SOLUTION: Upgrade to mod_ssl 2.8.7 or Apache_SSL 1.3.22+1.46, or apply the patch provided by your vendor.

VULNERABILITY
ASSESSMENT:
The risk is MEDIUM. To exploit the overflow, the server must be configured to allow client certificates, and an attacker must obtain a carefully crafted client certificate that has been signed by a Certificate Authority (CA) which is trusted by the server.

LINKS:  
  CIAC BULLETIN: http://www.ciac.org/ciac/bulletins/m-053.shtml
  ORIGINAL BULLETIN: http://www.kb.cert.org/vuls/id/234971

[***** Start CERT Vulnerability Note VU#234971 *****]

CERT Vulnerability Note VU#234971

mod_ssl and Apache_SSL modules contain a buffer overflow in the 
implementation of the OpenSSL "i2d_SSL_SESSION" routine

Overview

There is a remotely exploitable buffer overflow in two modules that 
implement the Secure Sockets Layer (SSL) and TLS protocol. This can 
be used to execute arbitrary code. 

I. Description

The Secure Sockets Layer (SSL) and Transport Layer Security (TLS) 
protocols are used to provide a secure connection between a client 
and server for higher level protocols such as HTTP. Apache_SSL and 
mod_ssl are two modules for Apache that both call an OpenSSL routine 
i2d_SSL_SESSION() to help create an SSL/TLS session. This routine 
converts the SSL/TLS session data into a format that can be stored 
in the session cache. The OpenSSL d2i_SSL_SESSION.pod document states 
that the routine should be called to first determine the size of the 
buffer needed to store the session data, the appropriately sized 
buffer should then be allocated, and then the routine should be 
called again to convert the data. 

These two modules fail to follow this procedure, and use a statically 
defined buffer to store the results of the i2d_SSL_SESSION() routine. 
By establishing an SSL Session, with a large crafted client certificate 
signed by a trusted CA, an attacker may be able to execute arbitrary 
code. If the target server trusts multiple CA's, then the target 
server's risk receiving a malicious certificate is increased.

Client certificates are generated when a Certificate Signature Request 
(CSR) is made of a Certificate Authority (CA), the CA signs the CSR 
with their server certificate and the resulting certificate is sent 
back to the client. Since some of the data contained in the CSR is 
entered by the person making the request it is possible to submit a 
large crafted CSR for signature, and have the CA sign it without 
suspicion. 

It should be noted that for testing purposes mod_ssl ships a static 
"snakeoil" CA server certificate. It is clearly stated that this 
certificate should not be used for production environments, and steps 
are given to dynamically generate a server certificate for the CA. If, 
however, a system uses this static "snakeoil" server certificate as 
their own CA signing certificate, then it is trivial for an attacker 
to craft, and sign their own client side certificate that would be 
accepted by the victim site as being signed by the trusted CA. The 
MD5 checksum for these static certificates from mod_ssl version 
2.8.4 for Apache version 1.3.20 are as follows:


9bd1d1069c69fafed5a86ea931ae45f9 ca-bundle.crt
b21689366a43829d83728b023b6d04b8 Makefile.crl
0de94cb2a39ed0fc158edd053b425255 Makefile.crt
fbb7ae5d7e39607a39b1e36d30048683 README.CRL
84bfd413a53d6a8036311b57faa8f0c8 README.CRT
a3351dacc96ebc615d986dfdb371c856 README.CSR
2284a70fae1cb3c1101494cff135f1f7 README.KEY
9a611f57078e624b672222197b8ff377 README.PRM
b269a8269073c62bd83e6635d56ec11b server.crt
4ff42eeddd6571a29e0a7682d06137e4 server.csr
ad5dc80749418c15c3d99962f00eb2b1 server.key
3c392576b27d8f79ab92eb39fce681f3 snakeoil-ca-dsa.crt
05cc51fdcc3c8ef6ed6a777f460e675a snakeoil-ca-dsa.key
3c9bf8ebd0586ce0633e7c6a85ed345a snakeoil-ca-dsa.prm
e76c1653eb00e4c2168a9c590fcf4ed7 snakeoil-ca-rsa.crt
a55527f1b3ad826052b8f6395d0da3e4 snakeoil-ca-rsa.key
d1701e1c69a9867943ad61432f1f44b1 snakeoil-dsa.crt
bc6e0ae4c628088f78e22c7287647b0a snakeoil-dsa.key
3c9bf8ebd0586ce0633e7c6a85ed345a snakeoil-dsa.prm
6c7a7d92f67c8dbd6ca57a30da7bc3bb snakeoil-rsa.crt
ec09a963da45ee792d5eb284568894da snakeoil-rsa.key
c98761828d8f030f973894f73e751e80 sslcfg.patch

It appears that most of these test files have not changed since 
1998-9 by the timestamp. 

II. Impact

An attacker may be able to execute arbitrary code on the system with 
the privileges of the ssl module. 

III. Solution

Upgrade to mod_ssl 2.8.7 or Apache_SSL 1.3.22+1.46, or apply the 
patch provided by your vendor. 

Systems Affected

Vendor 		Status 		      Date Updated 
Mod_ssl 	Vulnerable 	      1-Mar-2002 
Apache-SSL 	Vulnerable 	      1-Mar-2002 
Trustix 	Vulnerable 	      1-Mar-2002 
Engarde 	Vulnerable 	      1-Mar-2002 
Microsoft 	Not Vulnerable 	      4-Mar-2002 
Conectiva 	Vulnerable 	      4-Mar-2002 
Red Hat         Vulnerable            6-Mar-2002

References

http://archives.neohapsis.com/archives/bugtraq/2002-02/0313.html
http://www.apache-ssl.org/advisory-20020301.txt
http://www.trustix.net/errata/misc/2002/TSL-2002-0034-apache.asc.txt
http://www.linuxsecurity.com/advisories/other_advisory-1923.html
http://www.apacheweek.com/issues/02-03-01.html#security 

Credit

Ed Moyle discovered and analyzed this vulnerability. 

This document was written by Jason Rafail with assistance from 
Roman Danyliw, Sean Levy, and Jeff Havrilla. 

Other Information

Date Public 02/27/2002 
Date First Published 03/01/2002 05:52:19 PM 
Date Last Updated 03/04/2002 

CERT Advisory   
CVE Name CAN-2002-0082
Metric 15.50 
Document Revision 18 

[***** End CERT Vulnerability Note VU#234971 *****]


CIAC wishes to acknowledge the contributions of CERT/CC for the information contained in this bulletin.
DOE-CIRC can be contacted at:
    Voice:          +1 866-941-2472 (7 x 24)
    E-mail:          doecirc@doecirc.energy.gov
    World Wide Web:  http://www.doecirc.energy.gov/