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