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

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