Bug 743010 (CVE-2011-3597)

Summary: CVE-2011-3597 Perl Digest improper control of generation of code
Product: [Other] Security Response Reporter: Vincent Danen <vdanen>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: alee, awnuk, cfu, cweyl, iarnell, jmagne, kasal, lkundrak, mharmsen, mmaslano, nkinder, perl-maint-list, ppisar, psabata, psplicha, rc040203, rcvalle, tcallawa
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard: impact=moderate,public=20111002,reported=20111003,source=gentoo,cvss2=5.1/AV:N/AC:H/Au:N/C:P/I:P/A:P,rhel-4/perl=affected,rhel-5/perl=affected,rhel-6/perl=affected,fedora-all/perl=affected,certificate_system_7.3/perl=wontfix,directory_server_8/perl=wontfix
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-08 17:01:20 EST Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On: 743058, 743092, 743093, 743094, 743095, 743096    
Bug Blocks: 743013    
Attachments:
Description Flags
Fix for Perl 5.14.2 none

Description Vincent Danen 2011-10-03 11:13:18 EDT
A flaw was reported [1] in perl Digest module's "Digest->new()" function, which did not properly sanitize input before using it in an eval() call, which could possibly be exploited to inject and execute arbitrary perl code.

The flaw is fixed in version 1.17 [2] and affects at least as far back as perl 5.8.5.

The following patch will correct the flaw (selectively taken from upstream's 1.16->1.17 differences):

--- Digest.pm.org       2011-10-03 09:10:29.019681252 -0600
+++ Digest.pm   2011-10-03 09:11:18.630250656 -0600
@@ -35,7 +35,9 @@ sub new
        ($class, @args) = @$class if ref($class);
        no strict 'refs';
        unless (exists ${"$class\::"}{"VERSION"}) {
-           eval "require $class";
+           my $pm_file = $class . ".pm";
+           $pm_file =~ s{::}{/}g;
+           eval { require $pm_file };
            if ($@) {
                $err ||= $@;
                next;

[1] https://secunia.com/advisories/46279/
[2] http://cpansearch.perl.org/src/GAAS/Digest-1.17/Changes
Comment 1 Vincent Danen 2011-10-03 11:19:06 EDT
If we go with AC:H, then CVSSv2 drops to 5.1 (and moderate impact).
Comment 2 Vincent Danen 2011-10-03 13:51:36 EDT
Created perl tracking bugs for this issue

Affects: fedora-all [bug 743058]
Comment 3 Ramon de C Valle 2011-10-03 15:07:27 EDT
To successfully exploit this vulnerability, the attacker must already be able to execute Perl code or be able to set the algorithm name to be used by the constructor in the form "$ctx = Digest->new(XXX => $arg,...)", which is very unlikely to happen.

For additional information, refer to:
http://perldoc.perl.org/Digest.html
Comment 5 Petr Pisar 2011-10-04 05:41:59 EDT
The code in comment #3 assumes attacker can insert his own Digest::XXX module into Perl search path which itself is more serious problem.

Original test case in CPAN RT (https://rt.cpan.org/Public/Bug/Display.html?id=71390#txn-983600) does not need such privilege.
Comment 6 Tomas Hoger 2011-10-04 06:07:31 EDT
This can be triggered when deserializing specially-crafted input using Data::Serializer.  Not sure if that actually makes any real difference.  In several serialization frameworks, it is assumed you should not deserialize any untrusted input, as that can lead to code execution.  Data::Serializer documentation does not seem to mention that in any way.
Comment 7 Petr Pisar 2011-10-04 09:11:13 EDT
Created attachment 526246 [details]
Fix for Perl 5.14.2
Comment 8 Fedora Update System 2011-10-24 19:03:24 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:07 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:38 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:11 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
Comment 12 errata-xmlrpc 2011-12-08 14:06:23 EST
This issue has been addressed in following products:

  Red Hat Enterprise Linux 4
  Red Hat Enterprise Linux 5

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