Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 79600 - net-misc/openswan: XAUTH/PAM Buffer Overflow Vulnerability
Summary: net-misc/openswan: XAUTH/PAM Buffer Overflow Vulnerability
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Gentoo Security
URL: http://www.idefense.com/application/p...
Whiteboard: ?1? [stable]
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-26 09:54 UTC by Luke Macken (RETIRED)
Modified: 2005-01-27 03:02 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luke Macken (RETIRED) gentoo-dev 2005-01-26 09:54:35 UTC
Openswan XAUTH/PAM Buffer Overflow Vulnerability

iDEFENSE Security Advisory 01.26.05:

I. BACKGROUND

Openswan is an open source implementation of IPSEC for the Linux
Operating System. Openswan is based on the discontinued FreeS/WAN
project.

More information is available on the vendor's website:
http://www.openswan.org/

II. DESCRIPTION

Remote exploitation of a stack based buffer overflow vulnerability in
Xelerance Corp.'s Openswan could allow attackers to execute arbitrary
code.

The vulnerability specifically exists due to a lack of bounds checking
in the pluto application when Openswan is compiled with XAUTH and PAM
support. The get_internal_addresses() function in
programs/pluto/xauth.c allocates a small character array and copies an
overly long user controlled buffer into the array as seen below. The
resulting stack overflow may be leveraged to execute arbitrary code
with permissions of the pluto process.

in programs/pluto/id.h:

47:  #define IDTOA_BUF 512


in programs/pluto/xauth.c:

148: #ifdef XAUTH_USEPAM
149: int retval;
150: char str[48];
151: #endif
...
169: if(retval == PAM_SUCCESS)
170: {
171:  char buf[IDTOA_BUF];
...
185:  sprintf(str,"ID=%s", buf);

III. ANALYSIS

Successful exploitation of the vulnerability can allow remote attackers
to execute code with privileges of the pluto process. Exploitation in
the wild will be limited due to the fact that Openswan would need to be
compiled with XAUTH and PAM options enabled which are both disabled by
default. In addition, exploitation occurs after an IKE Phase-1 Security
Association (SA) has been established which requires authentication of
a shared key and the supplied client certificate, further reducing the
impact of this vulnerability.

IV. DETECTION

iDEFENSE has confirmed that Openswan 2.2.0 is vulnerable. All previous
versions of Openswan also contain the vulnerable code.

V. WORKAROUND

The XAUTH and PAM configuration options can be found in Makefile.inc in
the Openswan source tree. Disable both configuration options or apply
the following vendor-supplied patch:

Index: xauth.c
===================================================================
RCS file: /xelerance/master/openswan-2/programs/pluto/xauth.c,v
retrieving revision 1.35
diff -u -p -u -r1.35 xauth.c
- --- xauth.c 30 Nov 2004 15:30:24 -0000 1.35
+++ xauth.c 8 Jan 2005 02:25:35 -0000
@@ -187,7 +187,7 @@ int get_internal_addresses(struct connec  {  
 #ifdef XAUTH_USEPAM
     int retval;
- -    char str[48];
+    char str[IDTOA_BUF+sizeof("ID=")+2];
 #endif


 #ifdef NAT_TRAVERSAL /* only NAT-T code lets us do virtual ends */
@@ -222,7 +222,7 @@ int get_internal_addresses(struct connec
          memmove(buf, c1+3,
strlen(c1) + 1 - 3);
         }
        }
- -       sprintf(str,"ID=%s", buf);
+       snprintf(str, sizeof(str), "ID=%s", buf);
        pam_putenv(con->pamh,str);
        pam_open_session(con->pamh,0);
       }


VI. VENDOR RESPONSE

The vendor has addressed this vulnerability in newly released Openswan
packages. Users should upgrade to Openswan 1.0.9 or Openswan 2.3.0
depending on their current configuration. New packages are available
from the following link:

http://www.openswan.org/code/

VII. CVE INFORMATION

A Mitre Corp. Common Vulnerabilities and Exposures (CVE) number has not
been assigned yet.

VIII. DISCLOSURE TIMELINE

01/06/2005  Initial vendor notification
01/06/2005  Initial vendor response
01/26/2005  Public disclosure

IX. CREDIT

The discoverer of this vulnerability wishes to remain anonymous.

Get paid for vulnerability research
http://www.idefense.com/poi/teams/vcp.jsp

X. LEGAL NOTICES

Copyright 
Comment 1 Luke Macken (RETIRED) gentoo-dev 2005-01-26 09:54:35 UTC
Openswan XAUTH/PAM Buffer Overflow Vulnerability

iDEFENSE Security Advisory 01.26.05:

I. BACKGROUND

Openswan is an open source implementation of IPSEC for the Linux
Operating System. Openswan is based on the discontinued FreeS/WAN
project.

More information is available on the vendor's website:
http://www.openswan.org/

II. DESCRIPTION

Remote exploitation of a stack based buffer overflow vulnerability in
Xelerance Corp.'s Openswan could allow attackers to execute arbitrary
code.

The vulnerability specifically exists due to a lack of bounds checking
in the pluto application when Openswan is compiled with XAUTH and PAM
support. The get_internal_addresses() function in
programs/pluto/xauth.c allocates a small character array and copies an
overly long user controlled buffer into the array as seen below. The
resulting stack overflow may be leveraged to execute arbitrary code
with permissions of the pluto process.

in programs/pluto/id.h:

47:  #define IDTOA_BUF 512


in programs/pluto/xauth.c:

148: #ifdef XAUTH_USEPAM
149: int retval;
150: char str[48];
151: #endif
...
169: if(retval == PAM_SUCCESS)
170: {
171:  char buf[IDTOA_BUF];
...
185:  sprintf(str,"ID=%s", buf);

III. ANALYSIS

Successful exploitation of the vulnerability can allow remote attackers
to execute code with privileges of the pluto process. Exploitation in
the wild will be limited due to the fact that Openswan would need to be
compiled with XAUTH and PAM options enabled which are both disabled by
default. In addition, exploitation occurs after an IKE Phase-1 Security
Association (SA) has been established which requires authentication of
a shared key and the supplied client certificate, further reducing the
impact of this vulnerability.

IV. DETECTION

iDEFENSE has confirmed that Openswan 2.2.0 is vulnerable. All previous
versions of Openswan also contain the vulnerable code.

V. WORKAROUND

The XAUTH and PAM configuration options can be found in Makefile.inc in
the Openswan source tree. Disable both configuration options or apply
the following vendor-supplied patch:

Index: xauth.c
===================================================================
RCS file: /xelerance/master/openswan-2/programs/pluto/xauth.c,v
retrieving revision 1.35
diff -u -p -u -r1.35 xauth.c
- --- xauth.c 30 Nov 2004 15:30:24 -0000 1.35
+++ xauth.c 8 Jan 2005 02:25:35 -0000
@@ -187,7 +187,7 @@ int get_internal_addresses(struct connec  {  
 #ifdef XAUTH_USEPAM
     int retval;
- -    char str[48];
+    char str[IDTOA_BUF+sizeof("ID=")+2];
 #endif


 #ifdef NAT_TRAVERSAL /* only NAT-T code lets us do virtual ends */
@@ -222,7 +222,7 @@ int get_internal_addresses(struct connec
          memmove(buf, c1+3,
strlen(c1) + 1 - 3);
         }
        }
- -       sprintf(str,"ID=%s", buf);
+       snprintf(str, sizeof(str), "ID=%s", buf);
        pam_putenv(con->pamh,str);
        pam_open_session(con->pamh,0);
       }


VI. VENDOR RESPONSE

The vendor has addressed this vulnerability in newly released Openswan
packages. Users should upgrade to Openswan 1.0.9 or Openswan 2.3.0
depending on their current configuration. New packages are available
from the following link:

http://www.openswan.org/code/

VII. CVE INFORMATION

A Mitre Corp. Common Vulnerabilities and Exposures (CVE) number has not
been assigned yet.

VIII. DISCLOSURE TIMELINE

01/06/2005  Initial vendor notification
01/06/2005  Initial vendor response
01/26/2005  Public disclosure

IX. CREDIT

The discoverer of this vulnerability wishes to remain anonymous.

Get paid for vulnerability research
http://www.idefense.com/poi/teams/vcp.jsp

X. LEGAL NOTICES

Copyright © 2005 iDEFENSE, Inc.

Permission is granted for the redistribution of this alert
electronically. It may not be edited in any way without the express
written consent of iDEFENSE. If you wish to reprint the whole or any
part of this alert in any other medium other than electronically, please
email customerservice@idefense.com for permission.

Disclaimer: The information in the advisory is believed to be accurate
at the time of publishing based on currently available information. Use
of the information constitutes acceptance for use in an AS IS condition.
There are no warranties with regard to this information. Neither the
author nor the publisher accepts any liability for any direct, indirect,
or consequential loss or damage arising from use of, or reliance on,
this information.
Comment 2 Luke Macken (RETIRED) gentoo-dev 2005-01-26 10:34:58 UTC
pfeifer, please verify.
Comment 3 Thierry Carrez (RETIRED) gentoo-dev 2005-01-26 13:04:01 UTC
No confirmation from upstream yet... but 2.3.0 is already in portage, just requiring stable keywording. Calling arches...

x86, amd64: please test and mark 2.3.0 stable.
Comment 4 Jay Pfeifer (RETIRED) gentoo-dev 2005-01-26 14:44:03 UTC
I have confirmation from upstream relative to the 1.x series being vulnerable. 1.0.9 has the xauth fixes to address the issue. However, Gentoo users are not vulnerable unless they edited the makefile on their own (in the < 1.0.9 releases). I put no such option into the ebuilds for the 1.x series. I am working on the 1.0.9 release and will put it in portage when ready. I already put 2.3.0 (as koon mentioned) last week. I will check the openswan devs for the status of the 2.x series and post back the info.

Jay
Comment 5 Jay Pfeifer (RETIRED) gentoo-dev 2005-01-26 15:04:58 UTC
Okay, 2.3.0 is not vulnerable even if the Makefile for pluto were edited. However, the way the 2.x ebuilds are set, none of the earlier (< 2.3.0 verions) in Gentoo are vulnerable. It would only be if the end-user went outside our ebuilds and edited the pluto/Makefile. There is a 2.2.1 version planned with the fix as well.

Bottom line is this: Gentoo's openswan packages are not vulnerable unless the user went outside our ebuild system.

Jay
Comment 6 Thierry Carrez (RETIRED) gentoo-dev 2005-01-27 03:02:34 UTC
Our packages are safe and we ensure security within Portage, not kitchen sink manual builds. Closing as WORKSFORME