Bug 731246 - (CVE-2011-2939) CVE-2011-2939 Perl decode_xs heap-based buffer overflow
CVE-2011-2939 Perl decode_xs heap-based buffer overflow
Status: CLOSED ERRATA
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Red Hat Product Security
impact=moderate,public=20110809,repor...
: Security
Depends On: 743087 743088 743089 743090 743091 743266
Blocks: 732123
  Show dependency treegraph
 
Reported: 2011-08-17 02:59 EDT by Petr Pisar
Modified: 2016-11-08 11:07 EST (History)
12 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-11-03 17:16:10 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)

  None (edit)
Description Petr Pisar 2011-08-17 02:59:05 EDT
Perl bundles `Encode' module (http://search.cpan.org/~dankogai/Encode/) that contains `Unicode.xs' file where a heap overflow bug has been fixed recently (http://cpansearch.perl.org/src/DANKOGAI/Encode-2.44/Changes):

$Revision: 2.44 $ $Date: 2011/08/09 07:49:44 $
! Unicode/Unicode.xs
  Addressed the following:
    Date: Fri, 22 Jul 2011 13:58:43 +0200
    From: Robert Zacek <zacek@avast.com>
    To: perl5-security-report@perl.org
    Subject: Unicode.xs!decode_xs n-byte heap-overflow

The patch has been merged into perl development tree (http://perl5.git.perl.org/perl.git/commitdiff/e46d973584785af1f445c4dedbee4243419cb860#patch5):


diff --git a/cpan/Encode/Unicode/Unicode.xs b/cpan/Encode/Unicode/Unicode.xs

index 16f4cd1..039f155 100644 (file)


--- a/cpan/Encode/Unicode/Unicode.xs
+++ b/cpan/Encode/Unicode/Unicode.xs
@@ -1,5 +1,5 @@
 /*
- $Id: Unicode.xs,v 2.7 2010/12/31 22:48:48 dankogai Exp $
+ $Id: Unicode.xs,v 2.8 2011/08/09 07:49:44 dankogai Exp dankogai $
  */
 
 #define PERL_NO_GET_CONTEXT
@@ -256,7 +256,10 @@ CODE:
               This prevents allocating too much in the rogue case of a large
               input consisting initially of long sequence uft8-byte unicode
               chars followed by single utf8-byte chars. */
-           STRLEN remaining = (e - s)/usize;
+            /* +1 
+               fixes  Unicode.xs!decode_xs n-byte heap-overflow
+              */
+           STRLEN remaining = (e - s)/usize + 1; /* +1 to avoid the leak */
            STRLEN max_alloc = remaining + (8*1024*1024);
            STRLEN est_alloc = remaining * UTF8_MAXLEN;
            STRLEN newlen = SvLEN(result) + /* min(max_alloc, est_alloc) */

Debian has applied the fix for Perl 5.12 and 5.14 versions (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=637376) so far but recognized the bug in all Perl releases since 5.10.0.

No reproducer or other details are known now. This flaw is public.
Non-replied question has been post to perl-ports mailing list (http://permalink.gmane.org/gmane.comp.lang.perl.perl5.porters/98004).
Comment 1 Vincent Danen 2011-08-19 16:52:05 EDT
This was assigned the name CVE-2011-2939:

http://www.openwall.com/lists/oss-security/2011/08/19/17

As noted in the email, it looks like a single byte overflow that probably is not exploitable.
Comment 3 Ramon de C Valle 2011-10-03 12:44:34 EDT
When remaining is zero, max_alloc is 8*1024*1024 and est_alloc is zero, thus est_alloc is used for newlen. It results in resultbuf and resultbuflen being unmodified, where it should they should be at least increased by UTF8_MAXLEN.
Comment 4 Ramon de C Valle 2011-10-03 13:11:27 EDT
This issue could result in a 13 bytes overflow of resultbuf, which for Perl's UTF-8 is how wide can a single UTF-8 encoded character become in bytes.
Comment 7 Ramon de C Valle 2011-10-04 08:47:00 EDT
Created perl tracking bugs for this issue

Affects: fedora-all [bug 743266]
Comment 8 Fedora Update System 2011-10-24 19:03:31 EDT
perl-5.12.4-162.fc15 has been pushed to the Fedora 15 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 9 Fedora Update System 2011-10-24 23:40:19 EDT
perl-5.14.1-188.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 10 Fedora Update System 2011-11-02 20:22:45 EDT
perl-5.12.4-147.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 11 errata-xmlrpc 2011-11-03 16:48:07 EDT
This issue has been addressed in following products:

  Red Hat Enterprise Linux 6

Via RHSA-2011:1424 https://rhn.redhat.com/errata/RHSA-2011-1424.html

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