Bug 731246 (CVE-2011-2939) - CVE-2011-2939 Perl decode_xs heap-based buffer overflow
Summary: CVE-2011-2939 Perl decode_xs heap-based buffer overflow
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2011-2939
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 743087 743088 743089 743090 743091 743266
Blocks: 732123
TreeView+ depends on / blocked
 
Reported: 2011-08-17 06:59 UTC by Petr Pisar
Modified: 2019-09-29 12:46 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-11-03 21:16:10 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:1424 normal SHIPPED_LIVE Moderate: perl security update 2011-11-04 00:47:59 UTC

Description Petr Pisar 2011-08-17 06:59:05 UTC
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 20:52:05 UTC
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 16:44:34 UTC
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 17:11:27 UTC
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 12:47:00 UTC
Created perl tracking bugs for this issue

Affects: fedora-all [bug 743266]

Comment 8 Fedora Update System 2011-10-24 23:03:31 UTC
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-25 03:40:19 UTC
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-03 00:22:45 UTC
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 20:48:07 UTC
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.