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:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-08 22:01:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
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 15:13:18 UTC
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 15:19:06 UTC
If we go with AC:H, then CVSSv2 drops to 5.1 (and moderate impact).

Comment 2 Vincent Danen 2011-10-03 17:51:36 UTC
Created perl tracking bugs for this issue

Affects: fedora-all [bug 743058]

Comment 3 Ramon de C Valle 2011-10-03 19:07:27 UTC
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 09:41:59 UTC
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 10:07:31 UTC
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 13:11:13 UTC
Created attachment 526246 [details]
Fix for Perl 5.14.2

Comment 8 Fedora Update System 2011-10-24 23:03:24 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:07 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:38 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:11 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

Comment 12 errata-xmlrpc 2011-12-08 19:06:23 UTC
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