SecurityTracker.com
Keep Track of the Latest Vulnerabilities
with SecurityTracker!
    Home    |    View Topics    |    Search    |    Contact Us    |    Help    |   

SecurityTracker
Archives


Welcome to SecurityTracker!
 
Click to Sign Up
Sign Up
Sign Up for Your FREE Weekly SecurityTracker E-mail Alert Summary
Instant Alerts
Buy our Premium Vulnerability Notification Service to receive customized, instant alerts
Affiliates
Put SecurityTracker Vulnerability Alerts on Your Web Site -- It's Free!
Partners
Become a Partner and License Our Database or Notification Service
Report a Bug
Report a vulnerability that you have found to SecurityTracker
bugs
@
securitytracker.com

Sign Up!





Category:  Application (Web Server/CGI)  >  DeleGate Vendors:  Delegate.org
DeleGate Buffer Overflow in static ssl_prcert() Lets Remote Users Execute Arbitrary Code
SecurityTracker Alert ID:  1010083
CVE Reference:  GENERIC-MAP-NOMATCH   (Links to External Site)
Date:  May 6 2004
Impact:  Execution of arbitrary code via network, User access via network
Fix Available:  Yes   Vendor Confirmed:  Yes  
Version(s): 8.9.2 and prior versions
Description:  A buffer overflow vulnerability was reported in DeleGate in the SSLway filter. A remote user can execute arbitrary code on the target system.

Joel Eriksson of 0xbadc0ded.org reported that a remote user can send a certificate with a subject or issuer name that is larger than 256 bytes to trigger the overflow in 'filters/sslway.c' in the static ssl_prcert() function.

The vendor was reportedly notified on May 2, 2004.

The original advisory is available at:

http://0xbadc0ded.org/advisories/0401.txt

Impact:  A remote user can execute arbitrary code on the target system with the privileges of the DeleGate proxy process.
Solution:  The vendor has released a fixed version (8.9.3), available at:

ftp://ftp.delegate.org/pub/DeleGate/

Vendor URL:  www.delegate.org/delegate/ (Links to External Site)
Cause:  Boundary error
Underlying OS:  Linux (Any), UNIX (Any), Windows (Any)
Reported By:  Joel Eriksson <je-fulldisclosure@bitnux.com>
Message History:   None.


 Source Message Contents

Date:  Thu, 6 May 2004 13:35:41 +0200
From:  Joel Eriksson <je-fulldisclosure@bitnux.com>
Subject:  [Full-Disclosure] [0xbadc0ded #03] DeleGate (SSL-filter) &lt;= 8.9.2

 

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

==========================================================================
0xbadc0ded Advisory #03 - 2004/05/06 - DeleGate <= 8.9.2 (SSL-filter)
==========================================================================

Reference      http://0xbadc0ded.org/advisories/0401.txt
PGP-key        http://0xbadc0ded.org/advisories/pubkey.asc

Application    DeleGate <= 8.9.2 (SSL-filter)
Discovered By  Joel Eriksson <je@bitnux.com>
Researched By  Joel Eriksson <je@bitnux.com>

Overview

  DeleGate is a multi-purpose application level gateway which runs on
  a variety of platforms, such as Unix, Windows, MacOS X and OS/2.
  DeleGate can be used to mediate communication of various protocols,
  including but not limited to HTTP, FTP, NTTP, SMTP, POP, Telnet and
  SOCKS. It has the ability to apply caching and conversion for mediated
  data, access control from clients and routing towards servers. It
  is also able to translate between protocols and apply SSL (TLS) to
  arbitrary protocols.

Problem

  A remotely exploitable buffer overflow vulnerability exists in the
  SSLway filter that is used when SSL should be applied to a client
  or server connection.

  The bug can be triggered using a certificate with field contents
  large enough to make the subject or issuer name larger than 256 bytes.
  The vulnerability is caused by this piece of code in filters/sslway.c:

    static ssl_prcert(ssl,show,outssl,outfd,what)
            SSL *ssl;
            char *what;
    {       X509 *peer;
            char subjb[256],*sb,issrb[256],*is;
            char *dp,ident[256];
    
            ident[0] = 0;
            if( peer = SSL_get_peer_certificate(ssl) ){
                    sb = X509_NAME_oneline(X509_get_subject_name(peer),subjb,1024);
                    is = X509_NAME_oneline(X509_get_issuer_name(peer),issrb,1024);

  The second argument to X509_NAME_oneline() is the buffer to write to and
  the third argument is the size of that buffer. In the case above a
  buffer size of 1024 is specified, but the buffers are only 256 bytes
  large. This allows us to, for instance, overwrite the saved return
  address in ssl_prcert()'s stack frame.

Exploit
 
  X509_NAME_oneline() converts chars below 0x20 or above 0x7e to '\xHH'
  where HH is the hexadecimal value of the char. This makes the bug pretty
  hard to exploit on at least x86 Unix variants since we will usually need
  to write chars outside that range to construct a valid address where we
  can place shellcode. Creative use of a partially overwritten pointer or
  address is likely to be possible, but I haven't investigated that
  thouroughly.

  For instance, the "peer" or "ssl" pointers may be of use, since at least
  the SSL struct contains pointers to callback functions, and of course
  partially overwriting the saved ebp or eip is a possibility. Any pointer
  that is dereferenced and written or called to can possibly be abused.

  What I find most ironic about this flaw and other flaws where a
  restricted set of characters can be written is that the address space
  randomization feature in kernel patches such as PaX can actually make
  the flaws easier to exploit. The sendmail prescan() bug comes to mind..

  The only protection against standard return-to-lib(c) techniques in PaX
  is address space randomization, with 16 bits of entropy (e.g. 65536
  possibilities). This means bruteforcing the offset can be done in a few
  minutes on most systems.

  For bugs that the attacker only has one shot to succeed with,
  randomization may be considered good enough by some. However, in the
  case of daemons that handle each connection in a separate process (which
  is the case here) or for local SUID/SGID vulnerabilities, randomization
  is no adequate protection.

  To create an SSL certificate that can be used to trigger this bug, it's
  easiest to use the OpenSSL command line tool:

    [je@vudo ~]$ cat>openssl.cnf<<EOF
    > [ req ]
    > distinguished_name = req_dn
    > prompt = no
    > [ req_dn ]
    > CN=bof
    > 0.OU=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    > 1.OU=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    > 2.OU=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    > 3.OU=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    EOF
    [je@vudo ~]$ openssl req -x509 -new -nodes -out bof.pem -keyout bof.pem -config openssl.cnf
    Generating a 512 bit RSA private key
    .........++++++++++++
    ..........++++++++++++
    writing new private key to 'bof.pem'

  For an example of an actual exploit using the return-to-lib(c) technique
  to defeat address space randomization as provided by PaX, and possibly
  also restricted charset such as in X509_NAME_oneline(), take a look at:

    http://0xbadc0ded.org/exploits/pax-poc.tar.gz

Fix

  Upgrade to DeleGate 8.9.3 or edit filters/sslway.c and change:

    sb = X509_NAME_oneline(X509_get_subject_name(peer),subjb,1024);
    is = X509_NAME_oneline(X509_get_issuer_name(peer),issrb,1024);

  to:

    sb = X509_NAME_oneline(X509_get_subject_name(peer),subjb,sizeof(subjb));
    is = X509_NAME_oneline(X509_get_issuer_name(peer),issrb,sizeof(issrb));

Disclosure Timeline

  2004/05/02 Notified the DeleGate team
  2004/05/05 DeleGate 8.9.3 was released with fix (without notifying us)
  2004/05/06 Public release

==========================================================================
The 0xbadc0ded.org team is hosted and sponsored by Bitnux: www.bitnux.com
==========================================================================

Bitnux is a company located in Sweden focused on security
research and system development. We offer services such as:

  - Code Reviews
  - Exploit Development
  - Reverse Engineering of Code
  - Security Revisions of Systems and Software
  - Custom System Development for Unix/Linux/BSD and Windows

E-mail : info@bitnux.com
Phone  : +46-70-228 64 16
Chat   : http://bitnux.com/live

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQFAmiNuqnq6VG/4jhQRAokjAKDQbc79S5KGkawUYBSAyPnVaF6RKACeJimZ
d3DpniP2OMX/HiCEHKuAGaA=
=jfZJ
-----END PGP SIGNATURE-----

_______________________________________________
Full-Disclosure - We believe in it.
Charter: http://lists.netsys.com/full-disclosure-charter.html

 


Go to the Top of This SecurityTracker Archive Page





Home   |    View Topics   |    Search   |    Contact Us   |    Help

Copyright 2004, SecurityGlobal.net LLC