Blame SOURCES/Digest-0.17-CVE-2016-1238-prevent-loading-optional-modules-from-.patch

e8773e
From 8cfc4916736280dd76655fdef5b78331bfac414d Mon Sep 17 00:00:00 2001
e8773e
From: Tony Cook <tony@develop-help.com>
e8773e
Date: Wed, 27 Jul 2016 14:04:59 +1000
e8773e
Subject: [PATCH] CVE-2016-1238: prevent loading optional modules from default
e8773e
 .
e8773e
e8773e
Digest attempts to load Digest::SHA, only failing if Digest::SHA2
e8773e
is also unavailable.
e8773e
e8773e
If a system has Digest installed, but not Digest::SHA, and a user
e8773e
attempts to run a program using Digest with SHA-256 from a world
e8773e
writable directory such as /tmp and since perl adds "." to the end
e8773e
of @INC an attacker can run code as the original user by creating
e8773e
/tmp/Digest/SHA.pm.
e8773e
e8773e
The change temporarily removes the default "." entry from the end of
e8773e
@INC preventing that attack.
e8773e
---
e8773e
 Digest.pm | 6 +++++-
e8773e
 1 file changed, 5 insertions(+), 1 deletion(-)
e8773e
e8773e
diff --git a/Digest.pm b/Digest.pm
e8773e
index 2ae6eec..c75649f 100644
e8773e
--- a/Digest.pm
e8773e
+++ b/Digest.pm
e8773e
@@ -42,7 +42,11 @@ sub new
e8773e
         unless (exists ${"$class\::"}{"VERSION"}) {
e8773e
             my $pm_file = $class . ".pm";
e8773e
             $pm_file =~ s{::}{/}g;
e8773e
-            eval { require $pm_file };
e8773e
+            eval {
e8773e
+                local @INC = @INC;
e8773e
+                pop @INC if $INC[-1] eq '.';
e8773e
+                require $pm_file;
e8773e
+            };
e8773e
             if ($@) {
e8773e
                 $err ||= $@;
e8773e
                 next;
e8773e
-- 
e8773e
2.1.4
e8773e