Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 82534 - net-misc/curl Buffer overflows with Kerberos/NTLM
Summary: net-misc/curl Buffer overflows with Kerberos/NTLM
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Gentoo Security
URL:
Whiteboard: B2 [glsa] jaervosz
Keywords:
Depends on:
Blocks:
 
Reported: 2005-02-18 23:55 UTC by Sune Kloppenborg Jeppesen
Modified: 2005-08-15 21:33 UTC (History)
1 user (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 Sune Kloppenborg Jeppesen gentoo-dev 2005-02-18 23:55:27 UTC
Multiple Unix/Linux Vendor cURL/libcURL Kerberos Authentication Buffer Overflow Vulnerability

iDEFENSE Security Advisory 02.21.05:
http://www.idefense.com/application/poi/display?type=vulnerabilities
February 21, 2005

I. BACKGROUND

cURL is a command line tool for transferring files with URL syntax,
supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP.
More information about cURL and libcURL is available from:

    http://curl.haxx.se/

II. DESCRIPTION

Remote exploitation of a stack-based buffer overflow in various Unix /
Linux vendors' implementation of cURL could allow for arbitrary code
execution on the targeted host.

An exploitable stack-based buffer overflow condition exists when using
Kerberos authentication. The problem specifically exists within the
functions Curl_krb_kauth() and krb4_auth() defined in lib/krb4.c.
Within these functions a statically allocated stack-based buffer of size
1250, from struct KTEXT_ST.dat, is passed to the Curl_base64_decode()
routine defined in lib/base64.c as can be seen here:

    len = Curl_base64_decode(p, (char *)adat.dat);
    tmp = Curl_base64_decode(p, (char *)tkt.dat);

The Curl_base64_decode() routine relies on the calling function to
validate the decoded length. This function base64 decodes and copies
data directly from the HTTP reply of a server to the destination buffer,
in this case buffer[]. An attacker can construct a long base64 encoded
malicious payload that upon decoding will overflow the static buffer and
overwrite the saved EIP. This in turn can lead to arbitrary code
execution.

III. ANALYSIS

Sucessful exploitation allows remote attackers to execute arbitary code
under the privileges of the target user. Exploitation requires that an
attacker either cooerce or force a target to connect to a malicious
server using Kerberos authentication.

IV. DETECTION

iDEFENSE has confirmed the existence of this vulnerability in cURL
version 7.12.1. It is suspected that prior versions are affected as well.
Any application built using a vulnerable version libcURL will also be
affected.

V. WORKAROUND

Recompile cURL without Kerberos support if it is not needed.

VI. VENDOR RESPONSE

TBD

VII. CVE INFORMATION

TBD

VIII. DISCLOSURE TIMELINE

12/23/2004  Initial vendor notification - No response
02/10/2005  Secondary vendor notification - No response
02/21/2005  Public disclosure

IX. CREDIT

infamous41md[at]hotpop.com is credited with this discovery.

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

X. LEGAL NOTICES

Copyright 
Comment 1 Sune Kloppenborg Jeppesen gentoo-dev 2005-02-18 23:55:27 UTC
Multiple Unix/Linux Vendor cURL/libcURL Kerberos Authentication Buffer Overflow Vulnerability

iDEFENSE Security Advisory 02.21.05:
http://www.idefense.com/application/poi/display?type=vulnerabilities
February 21, 2005

I. BACKGROUND

cURL is a command line tool for transferring files with URL syntax,
supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP.
More information about cURL and libcURL is available from:

    http://curl.haxx.se/

II. DESCRIPTION

Remote exploitation of a stack-based buffer overflow in various Unix /
Linux vendors' implementation of cURL could allow for arbitrary code
execution on the targeted host.

An exploitable stack-based buffer overflow condition exists when using
Kerberos authentication. The problem specifically exists within the
functions Curl_krb_kauth() and krb4_auth() defined in lib/krb4.c.
Within these functions a statically allocated stack-based buffer of size
1250, from struct KTEXT_ST.dat, is passed to the Curl_base64_decode()
routine defined in lib/base64.c as can be seen here:

    len = Curl_base64_decode(p, (char *)adat.dat);
    tmp = Curl_base64_decode(p, (char *)tkt.dat);

The Curl_base64_decode() routine relies on the calling function to
validate the decoded length. This function base64 decodes and copies
data directly from the HTTP reply of a server to the destination buffer,
in this case buffer[]. An attacker can construct a long base64 encoded
malicious payload that upon decoding will overflow the static buffer and
overwrite the saved EIP. This in turn can lead to arbitrary code
execution.

III. ANALYSIS

Sucessful exploitation allows remote attackers to execute arbitary code
under the privileges of the target user. Exploitation requires that an
attacker either cooerce or force a target to connect to a malicious
server using Kerberos authentication.

IV. DETECTION

iDEFENSE has confirmed the existence of this vulnerability in cURL
version 7.12.1. It is suspected that prior versions are affected as well.
Any application built using a vulnerable version libcURL will also be
affected.

V. WORKAROUND

Recompile cURL without Kerberos support if it is not needed.

VI. VENDOR RESPONSE

TBD

VII. CVE INFORMATION

TBD

VIII. DISCLOSURE TIMELINE

12/23/2004  Initial vendor notification - No response
02/10/2005  Secondary vendor notification - No response
02/21/2005  Public disclosure

IX. CREDIT

infamous41md[at]hotpop.com is credited with this discovery.

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 Sune Kloppenborg Jeppesen gentoo-dev 2005-02-18 23:57:41 UTC
Another one:

Multiple Unix/Linux Vendor cURL/libcURL NTLM Authentication Buffer Overflow Vulnerability

iDEFENSE Security Advisory 02.21.05:
http://www.idefense.com/application/poi/display?type=vulnerabilities
February 21, 2005

I. BACKGROUND

cURL is a command line tool for transferring files with URL syntax,
supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP.
More information about cURL and libcURL is available from:

    http://curl.haxx.se/

II. DESCRIPTION

Remote exploitation of a stack-based buffer overflow in various Unix /
Linux vendors' implementation of cURL could allow for arbitrary code
execution on the targeted host.

An exploitable stack-based buffer overflow condition exists when using
NT Lan Manager (NTLM) authentication. The problem specifically exists
within Curl_input_ntlm() defined in lib/http_ntlm.c. Within this
function an unsigned stack-based character array of size 256, buffer[],
is passed to the Curl_base64_decode() routine defined in lib/base64.c as
can be seen here:

    size_t size = Curl_base64_decode(header, (char *)buffer);

The Curl_base64_decode() routine relies on the calling function to
validate the decoded length. This function base64 decodes and copies
data directly from the HTTP reply of a server to the destination buffer,
in this case buffer[]. An attacker can construct a long base64 encoded
malicious payload that upon decoding will overflow the 256 byte static
buffer and overwrite the saved EIP. This in turn can lead to arbitrary
code execution.

III. ANALYSIS

Sucessful exploitation allows remote attackers to execute arbitary code
under the privileges of the target user. Exploitation requires that an
attacker either cooerce or force a target to connect to a malicious
server using NTLM authentication.

IV. DETECTION

iDEFENSE has confirmed the existence of this vulnerability in cURL
version 7.12.1. It is suspected that prior versions are affected as well.
Any application built using a vulnerable version libcURL will also be
affected.

V. WORKAROUND

Replace that static buffer allocation on line 106 in lib/http_ntlm.c:

    unsigned char buffer[256];

With a dynamic buffer allocation:

    unsigned char *buffer = (unsigned char *)malloc(strlen(header));

and recompile cURL.

VI. VENDOR RESPONSE

TBD

VII. CVE INFORMATION

TBD

VIII. DISCLOSURE TIMELINE

12/21/2004  Initial vendor notification - No response
02/10/2005  Secondary vendor notification - No response
02/21/2005  Public disclosure

IX. CREDIT

infamous41md[at]hotpop.com is credited with this discovery.

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

X. LEGAL NOTICES

Copyright 
Comment 3 Sune Kloppenborg Jeppesen gentoo-dev 2005-02-18 23:57:41 UTC
Another one:

Multiple Unix/Linux Vendor cURL/libcURL NTLM Authentication Buffer Overflow Vulnerability

iDEFENSE Security Advisory 02.21.05:
http://www.idefense.com/application/poi/display?type=vulnerabilities
February 21, 2005

I. BACKGROUND

cURL is a command line tool for transferring files with URL syntax,
supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP.
More information about cURL and libcURL is available from:

    http://curl.haxx.se/

II. DESCRIPTION

Remote exploitation of a stack-based buffer overflow in various Unix /
Linux vendors' implementation of cURL could allow for arbitrary code
execution on the targeted host.

An exploitable stack-based buffer overflow condition exists when using
NT Lan Manager (NTLM) authentication. The problem specifically exists
within Curl_input_ntlm() defined in lib/http_ntlm.c. Within this
function an unsigned stack-based character array of size 256, buffer[],
is passed to the Curl_base64_decode() routine defined in lib/base64.c as
can be seen here:

    size_t size = Curl_base64_decode(header, (char *)buffer);

The Curl_base64_decode() routine relies on the calling function to
validate the decoded length. This function base64 decodes and copies
data directly from the HTTP reply of a server to the destination buffer,
in this case buffer[]. An attacker can construct a long base64 encoded
malicious payload that upon decoding will overflow the 256 byte static
buffer and overwrite the saved EIP. This in turn can lead to arbitrary
code execution.

III. ANALYSIS

Sucessful exploitation allows remote attackers to execute arbitary code
under the privileges of the target user. Exploitation requires that an
attacker either cooerce or force a target to connect to a malicious
server using NTLM authentication.

IV. DETECTION

iDEFENSE has confirmed the existence of this vulnerability in cURL
version 7.12.1. It is suspected that prior versions are affected as well.
Any application built using a vulnerable version libcURL will also be
affected.

V. WORKAROUND

Replace that static buffer allocation on line 106 in lib/http_ntlm.c:

    unsigned char buffer[256];

With a dynamic buffer allocation:

    unsigned char *buffer = (unsigned char *)malloc(strlen(header));

and recompile cURL.

VI. VENDOR RESPONSE

TBD

VII. CVE INFORMATION

TBD

VIII. DISCLOSURE TIMELINE

12/21/2004  Initial vendor notification - No response
02/10/2005  Secondary vendor notification - No response
02/21/2005  Public disclosure

IX. CREDIT

infamous41md[at]hotpop.com is credited with this discovery.

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 4 Luke Macken (RETIRED) gentoo-dev 2005-02-21 12:55:50 UTC
This issue is now public.
Comment 5 Luke Macken (RETIRED) gentoo-dev 2005-02-21 12:57:18 UTC
CCing maintainer.
Comment 6 Matthias Geerdsen (RETIRED) gentoo-dev 2005-02-23 05:05:22 UTC
http://curl.haxx.se/

libcurl NTLM Buffer Overflow  	22 February 2005
As was posted to bugtraq, all versions of curl that supports NTLM has this flaw. The fix. It requires a malicious server to send an unexpectedly long NTLM response header to trigger. (No, we were not contacted nor notified about this problem before they went public.)

I'll be away for a week now but I'll put together a new release when I get back.

CAN-2005-0490 

_______________

Link is given to the following fix:
http://cool.haxx.se/cvs.cgi/curl/lib/http_ntlm.c.diff?r1=1.36&r2=1.37

A bug was posted for the kerberos issue at
http://sourceforge.net/tracker/index.php?func=detail&aid=1149607&group_id=976&atid=100976

Work seems to have also been done on that issue I'd say after a quick look to the CVS repo.
Comment 7 Thierry Carrez (RETIRED) gentoo-dev 2005-03-02 03:25:58 UTC
CAN-2005-0940
Ubuntu Security Notice USN-86-1
We should look for patches somewhere
Comment 8 Thierry Carrez (RETIRED) gentoo-dev 2005-03-04 06:31:19 UTC
7.13.1 is out :
http://curl.haxx.se/mail/archive-2005-03/0036.html

liquidx: please bump
Comment 9 Alastair Tse (RETIRED) gentoo-dev 2005-03-08 09:28:27 UTC
sorry .. i've just only got back to dev'ing after a long break. curl has been bumped but not in stable yet. will report back when i've got that done.
Comment 10 Sune Kloppenborg Jeppesen gentoo-dev 2005-03-09 13:03:26 UTC
Alastair arch teams will mark stable for you.

http://www.gentoo.org/security/en/vulnerability-policy.xml

Arch teams please test and mark curl-7.13.1 stable.
Comment 11 Michael Hanselmann (hansmi) (RETIRED) gentoo-dev 2005-03-09 13:37:31 UTC
curl and pycurl stable on ppc.
Comment 12 Jan Brinkmann (RETIRED) gentoo-dev 2005-03-09 13:44:46 UTC
stable on amd64
Comment 13 Markus Rothe (RETIRED) gentoo-dev 2005-03-09 22:52:37 UTC
stable on ppc64
Comment 14 Gustavo Zacarias (RETIRED) gentoo-dev 2005-03-10 05:54:54 UTC
sparc stable.
Comment 15 Bryan Østergaard (RETIRED) gentoo-dev 2005-03-11 20:53:20 UTC
Stable on alpha.
Comment 16 Matthias Geerdsen (RETIRED) gentoo-dev 2005-03-12 08:35:41 UTC
marked stable on x86 already, liquidx, pls comment on bug next time


curl-7.13.1.ebuild

revision 1.5
date: 2005/03/10 11:29:14;  author: liquidx;  state: Exp;  lines: +2 -2
stable for x86
(Portage version: 2.0.51.19)
Comment 17 Hardave Riar (RETIRED) gentoo-dev 2005-03-13 00:38:58 UTC
Stable on mips.
Comment 18 Guy Martin (RETIRED) gentoo-dev 2005-03-14 22:56:19 UTC
Stable on hppa thanks to vapie.
Comment 19 Sune Kloppenborg Jeppesen gentoo-dev 2005-03-16 08:51:15 UTC
GLSA 200503-20

arm, s390 please remember to mark stable to benifit from the GLSA.