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