Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 125766 - net-misc/curl: tftp:// URL Buffer Overflow (CVE-2006-1061)
Summary: net-misc/curl: tftp:// URL Buffer Overflow (CVE-2006-1061)
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Security
Classification: Unclassified
Component: Vulnerabilities (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Security
URL: http://curl.haxx.se/docs/adv_20060320...
Whiteboard: B2 [glsa]
Keywords: InVCS
: 126942 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-03-10 15:09 UTC by Tavis Ormandy (RETIRED)
Modified: 2007-05-31 10:55 UTC (History)
8 users (show)

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


Attachments
curl-7.15-libtftp.patch (curl-7.15-libtftp.patch,651 bytes, patch)
2006-03-19 03:45 UTC, solar (RETIRED)
no flags Details | Diff
curl-7.15.1-r1.ebuild (curl-7.15.1-r1.ebuild,2.29 KB, text/plain)
2006-03-19 03:46 UTC, solar (RETIRED)
no flags Details
curl-7.15.2-r1.ebuild (curl-7.15.2-r1.ebuild,2.25 KB, text/plain)
2006-03-19 03:47 UTC, solar (RETIRED)
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tavis Ormandy (RETIRED) gentoo-dev 2006-03-10 15:09:43 UTC
A message received at security@gentoo.org

From: Ulf Harnhammar <metaur@operamail.com>
Date: Fri, 10 Mar 2006 16:32:13 +0100
Subject: cURL tftp:// URL Buffer Overflow

cURL tftp:// URL Buffer Overflow

There is a buffer overflow in cURL when it fetches a tftp:// URL
with a size of >66000 characters. The URL must start with "tftp://",
then a valid hostname, and then another slash.

The bug affects cURL versions 7.15.2, 7.15.1 and 7.15.0.
<snip more details>

Ulf provides the following patch:

--- curl-7.15.1_UNPATCHED/lib/tftp.c
+++ curl-7.15.1/lib/tftp.c
@@ -271,7 +271,7 @@
        /* If we are downloading, send an RRQ */
        state->spacket.event = htons(TFTP_EVENT_RRQ);
      }
-    sprintf((char *)state->spacket.u.request.data, "%s%c%s%c",
+    snprintf((char *)state->spacket.u.request.data, 512, "%s%c%s%c",
              filename, '\0',  mode, '\0');
      sbytes = 4 + (int)strlen(filename) + (int)strlen(mode);
      sbytes = sendto(state->sockfd, (void *)&state->spacket,
Comment 1 Tavis Ormandy (RETIRED) gentoo-dev 2006-03-10 15:13:43 UTC
liquidx: please attach an updated ebuild to this bug if nescessary - do not commit anything to portage at this time, this bug is currently confidential.
Comment 2 Thierry Carrez (RETIRED) gentoo-dev 2006-03-12 03:43:22 UTC
Adjusting status
Comment 3 Thierry Carrez (RETIRED) gentoo-dev 2006-03-14 09:10:00 UTC
Embargo set to Monday 20th
Comment 4 Stefan Cornelius (RETIRED) gentoo-dev 2006-03-17 03:28:07 UTC
3 days till disclosure, still no ebuild
Comment 5 solar (RETIRED) gentoo-dev 2006-03-19 03:45:44 UTC
Created attachment 82532 [details, diff]
curl-7.15-libtftp.patch
Comment 6 solar (RETIRED) gentoo-dev 2006-03-19 03:46:35 UTC
Created attachment 82533 [details]
curl-7.15.1-r1.ebuild

stable series
Comment 7 solar (RETIRED) gentoo-dev 2006-03-19 03:47:17 UTC
Created attachment 82534 [details]
curl-7.15.2-r1.ebuild

~unstable series
Comment 8 Thierry Carrez (RETIRED) gentoo-dev 2006-03-19 07:14:00 UTC
Adding arch security liaisons. curl-7.15.1-r1 could be committed direct to stable on 2006/03/20 if you confirm it's stable on each of your arches.
Comment 9 Markus Rothe (RETIRED) gentoo-dev 2006-03-19 07:31:56 UTC
tested on ppc64. it's ok to commit directly to stable.
Comment 10 Mark Loeser (RETIRED) gentoo-dev 2006-03-19 10:22:00 UTC
x86 looks good to go
Comment 11 René Nussbaumer (RETIRED) gentoo-dev 2006-03-19 12:27:47 UTC
Looks good on hppa
Comment 12 Tobias Scherbaum (RETIRED) gentoo-dev 2006-03-19 13:00:07 UTC
Looks good on ppc.
Comment 13 Danny van Dyk (RETIRED) gentoo-dev 2006-03-19 13:27:47 UTC
I'm substituting blubb for this bug.
Both versions work on amd64. Tested with both curl's test-suite plus my printer's
tftp server.
Comment 14 solar (RETIRED) gentoo-dev 2006-03-20 01:06:17 UTC
This is public now (7.15.3 has been released) 
http://curl.haxx.se/docs/adv_20060320.html
Comment 15 Gustavo Zacarias (RETIRED) gentoo-dev 2006-03-20 05:30:27 UTC
Looks good for sparc, sorry for the delay but i'm usually off on weekends for some much needed air & rest.
Comment 16 Stefan Cornelius (RETIRED) gentoo-dev 2006-03-20 06:31:08 UTC
The issue is now public, opening. I think solar will commit the ebuild soon, alpha still needs to stable
Comment 17 Stefan Cornelius (RETIRED) gentoo-dev 2006-03-20 06:31:31 UTC
*** Bug 126942 has been marked as a duplicate of this bug. ***
Comment 18 Fernando J. Pereda (RETIRED) gentoo-dev 2006-03-20 06:39:32 UTC
The patch looks ok on Alpha too.
Comment 19 solar (RETIRED) gentoo-dev 2006-03-20 07:00:47 UTC
Ok I'll commit the ebuild .15-r1 to stable on the arches that gave feedback.
No reason to keep the .2 so I'll pump a .3 in the tree for ~arch users.
Comment 20 solar (RETIRED) gentoo-dev 2006-03-20 07:21:06 UTC
Everything is in the tree now. 

curl-7.15.1[0]: arm ia64 mips ~ppc-macos s390 sh
curl-7.15.1-r1[0]: alpha amd64 ~arm hppa ~ia64 ~mips ppc ~ppc-macos ppc64 ~s390 ~sh sparc x86
curl-7.15.3[0]: (M) ~alpha ~amd64 ~arm ~hppa ~ia64 ~mips ~ppc ~ppc-macos ~ppc64 ~s390 ~sh ~sparc ~x86
Comment 21 Thierry Carrez (RETIRED) gentoo-dev 2006-03-20 09:27:39 UTC
Ready for GLSA
Comment 22 Matthias Geerdsen (RETIRED) gentoo-dev 2006-03-21 11:38:59 UTC
Could someone please clarify the following a little bit, so that we don't state the wrong arches in the GLSA?

"libcurl 7.15.1 and 7.15.2 contain code that prevents this code from being
executed on architecures where a struct is not of the same assumed packed size
it has on x86, thus they are not vulnerable. For exact details on this, please
review the code and patch."
[from http://curl.haxx.se/docs/adv_20060320.html]

This appears to be the relevant part of the code I think:

/*
   * The TFTP code is not portable because it sends C structs directly over
   * the wire.  Since C gives compiler writers a wide latitude in padding and
   * aligning structs, this fails on many architectures (e.g. ARM).
   *
   * The only portable way to fix this is to copy each struct item into a
   * flat buffer and send the flat buffer instead of the struct.  The
   * alternative, trying to get the compiler to eliminate padding bytes
   * within the struct, is a nightmare to maintain (each compiler does it
   * differently), and is still not guaranteed to work because some
   * architectures can't handle the resulting alignment.
   *
   * This check can be removed once the code has been fixed.
   */
  if(sizeof(struct tftp_packet) != 516) {
    failf(conn->data, "tftp not supported on this architecture");
    return CURLE_FAILED_INIT;
  }

Comment 23 Matthias Geerdsen (RETIRED) gentoo-dev 2006-03-21 12:53:26 UTC
GLSA 200603-19

thanks everyone
Comment 24 Joshua Kinard gentoo-dev 2006-04-23 10:58:36 UTC
Stable on mips.