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