Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 635140 (CVE-2017-1000257)

Summary: <net-misc/curl-7.56.1: IMAP FETCH response out of bounds read
Product: Gentoo Security Reporter: Agostino Sarubbo <ago>
Component: VulnerabilitiesAssignee: Gentoo Security <security>
Status: RESOLVED FIXED    
Severity: normal CC: blueness, Manfred.Knick
Priority: Normal Flags: stable-bot: sanity-check+
Version: unspecified   
Hardware: All   
OS: Linux   
URL: https://curl.haxx.se/docs/adv_20171023.html
Whiteboard: A3 [glsa cve cleanup]
Package list:
net-misc/curl-7.56.1
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 633430    

Description Agostino Sarubbo gentoo-dev 2017-10-23 07:55:11 UTC
From ${URL} :

IMAP FETCH response out of bounds read
======================================

Project curl Security Advisory, October 23rd 2017 -
[Permalink](https://curl.haxx.se/docs/adv_20171023.html)

VULNERABILITY
-------------

libcurl contains a buffer overrun flaw in the IMAP handler.

An IMAP FETCH response line indicates the size of the returned data, in number
of bytes. When that response says the data is zero bytes, libcurl would pass
on that (non-existing) data with a pointer and the size (zero) to the
deliver-data function.

libcurl's deliver-data function treats zero as a magic number and invokes
strlen() on the data to figure out the length. The strlen() is called on a
heap based buffer that might not be zero terminated so libcurl might read
beyond the end of it into whatever memory lies after (or just crash) and then
deliver that to the application as if it was actually downloaded.

We are not aware of any exploit of this flaw.

INFO
----

This bug was introduced in commit
[ec3bb8f727](https://github.com/curl/curl/commit/ec3bb8f727), December 2009,
when the initial support for IMAP was introduced.

The Common Vulnerabilities and Exposures (CVE) project has assigned the name
CVE-2017-1000257 to this issue.

AFFECTED VERSIONS
-----------------

- Affected versions: libcurl 7.20.0 to and including 7.56.0
- Not affected versions: libcurl < 7.20.0 and >= 7.56.1

curl is used by many applications, but not always advertised as such.

THE SOLUTION
------------

In libcurl version 7.56.1, a zero bytes response is not passed on.

A [patch for CVE-2017-1000257](https://curl.haxx.se/CVE-2017-1000257.patch) is
available.

RECOMMENDATIONS
---------------

We suggest you take one of the following actions immediately, in order of
preference:

  A - Upgrade curl to version 7.56.1

  B - Apply the patch to your version and rebuild

  C - Switch off IMAP in `CURLOPT_PROTOCOLS`

TIME LINE
---------

It was reported to the curl project on October 6, 2017.  We contacted
distros@openwall on October 17.

curl 7.56.1 was released on October 23 2017, coordinated with the publication
of this advisory.

CREDITS
-------

Reported by Brian Carpenter, Geeknik Labs and 0xd34db347. Also independently
detected by and reported by the OSS-Fuzz project. Patch by Daniel Stenberg.



@maintainer(s): after the bump, in case we need to stabilize the package, please let us know if it is ready for the stabilization or not.
Comment 1 Jeroen Roovers gentoo-dev 2017-10-24 13:23:05 UTC
*** Bug 635284 has been marked as a duplicate of this bug. ***
Comment 2 Anthony Basile gentoo-dev 2017-10-24 21:14:39 UTC
(In reply to Agostino Sarubbo from comment #0)

> @maintainer(s): after the bump, in case we need to stabilize the package,
> please let us know if it is ready for the stabilization or not.

I just added it, and tested locally.  It should be ready for stabilization.

KEYWORDS="alpha amd64 arm hppa ia64 ppc ppc64 x86"
Comment 3 Sergei Trofimovich gentoo-dev 2017-10-24 21:37:25 UTC
Can you populate 'Package list' to speedup the process?

Thanks!
Comment 4 Sergei Trofimovich gentoo-dev 2017-10-25 07:07:35 UTC
ia64 stable
Comment 5 Agostino Sarubbo gentoo-dev 2017-10-25 09:32:16 UTC
amd64 stable
Comment 6 Thomas Deutschmann gentoo-dev Security 2017-10-26 17:38:49 UTC
x86 stable
Comment 7 Sergei Trofimovich gentoo-dev 2017-10-26 19:13:31 UTC
hppa stable
Comment 8 Sergei Trofimovich gentoo-dev 2017-10-26 21:48:03 UTC
ppc stable
Comment 9 Sergei Trofimovich gentoo-dev 2017-10-28 20:13:53 UTC
sparc stable (thanks to Rolf Eike Beer)
Comment 10 Sergei Trofimovich gentoo-dev 2017-10-28 22:23:09 UTC
ppc64 stable
Comment 11 Tobias Klausmann gentoo-dev 2017-11-08 12:53:02 UTC
Stable on alpha.
Comment 12 Aleksandr Wagner (Kivak) 2017-11-08 17:20:18 UTC
@ Maintainer(s): Stabilization is complete, please clean the vulnerable
versions from the tree.
Comment 13 Markus Meier gentoo-dev 2017-11-19 15:10:50 UTC
arm stable, all arches done.
Comment 14 D'juan McDonald (domhnall) 2017-11-29 04:37:26 UTC
Adjusting URL for accurate reference and preserving previous URL to respect reporter. 

Previous URL: http://www.openwall.com/lists/oss-security/2017/10/23/1

Gentoo Security Padawan
(jmbailey/mbailey_j)
Comment 15 D'juan McDonald (domhnall) 2017-12-03 03:27:50 UTC
New GLSA request filed.


Gentoo Security Padawan
(jmbailey/mbailey_j)
Comment 16 GLSAMaker/CVETool Bot gentoo-dev 2017-12-14 18:48:11 UTC
This issue was resolved and addressed in
 GLSA 201712-04 at https://security.gentoo.org/glsa/201712-04
by GLSA coordinator Thomas Deutschmann (whissi).