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