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