Bug 889935 - (CVE-2012-5667) CVE-2012-5667 grep: Integer overflow leading to heap-based buffer-overflow when reading large lines
CVE-2012-5667 grep: Integer overflow leading to heap-based buffer-overflow wh...
Status: CLOSED ERRATA
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
low Severity low
: ---
: ---
Assigned To: Red Hat Product Security
impact=low,public=20121222,reported=2...
: Security
Depends On: 1198218
Blocks: 889936 1183652 1193283
  Show dependency treegraph
 
Reported: 2012-12-23 23:57 EST by Huzaifa S. Sidhpurwala
Modified: 2015-07-22 14:12 EDT (History)
4 users (show)

See Also:
Fixed In Version: grep 2.11
Doc Type: Bug Fix
Doc Text:
An integer overflow flaw, leading to a heap-based buffer overflow, was found in the way grep parsed large lines of data. An attacker able to trick a user into running grep on a specially crafted data file could use this flaw to crash grep or, potentially, execute arbitrary code with the privileges of the user running grep.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-07-22 14:12:00 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Proposed fix (565 bytes, patch)
2013-01-24 04:18 EST, Jaroslav Škarvada
no flags Details | Diff
Proposed fix (to cover boundary case) (569 bytes, patch)
2013-01-24 04:44 EST, Jaroslav Škarvada
no flags Details | Diff

  None (edit)
Description Huzaifa S. Sidhpurwala 2012-12-23 23:57:00 EST
An integer overflow leading to a heap-based buffer overflow was found in the way grep, A utility used to search through textual input for lines which contain a match to a specified pattern, parsed large lines of data. This flaw could use used to crash grep or potentially execute arbitrary code, if a local user was tricked into running grep on a specially crafted data file.

Patch: http://git.savannah.gnu.org/cgit/grep.git/commit/?id=cbbc1a45b9f843c811905c97c90a5d31f8e6c189
Reference: http://seclists.org/oss-sec/2012/q4/504
Comment 1 Huzaifa S. Sidhpurwala 2012-12-24 01:53:11 EST
Upstream suggests that this issue only affects grep < 2.11
Comment 2 Huzaifa S. Sidhpurwala 2012-12-26 00:29:40 EST
This issue affects the version of grep package as shipped with Fedora-16. 

This issue does NOT affect the version of grep package as shipped with Fedora-17.
Comment 5 Jaroslav Škarvada 2013-01-04 11:25:20 EST
I am unable to reproduce the crash on F16.

64 bit machine with 4 GB RAM:
# perl -e 'print "x"x(2**31)' | grep x > /dev/null
grep: memory exhausted

# grep --version
grep (GNU grep) 2.9
Comment 7 Huzaifa S. Sidhpurwala 2013-01-21 04:44:58 EST
Statement:

This issue did not affect the version of grep as shipped with Red Hat Enterprise Linux 5.
Comment 10 Jaroslav Škarvada 2013-01-24 04:18:55 EST
Created attachment 686585 [details]
Proposed fix

This is proposed fix/workaround for the problem. It is not clean solution, but it shouldn't have side-effects.
Comment 12 Jaroslav Škarvada 2013-01-24 04:44:09 EST
Created attachment 686605 [details]
Proposed fix (to cover boundary case)

# perl -e 'print "x"x(1073741823)' | LANG=c grep x > /dev/null

# perl -e 'print "x"x(1073741824)' | LANG=c grep x > /dev/null
grep: line too long
Comment 15 errata-xmlrpc 2015-07-22 02:17:52 EDT
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 6

Via RHSA-2015:1447 https://rhn.redhat.com/errata/RHSA-2015-1447.html

Note You need to log in before you can comment on or make changes to this bug.