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

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