From 2506b5b6f05e60b8fce17e9ad00be929f9a96002 Mon Sep 17 00:00:00 2001 From: Stefan Brand Date: Tue, 11 Jan 2022 17:06:45 +0100 Subject: [PATCH] Prevent Path Traversal --- index.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/index.php b/index.php index 67d10ff..ac2e1c1 100644 --- a/index.php +++ b/index.php @@ -41,7 +41,11 @@ if (isset($_SESSION['files']) } else { $r_imagedir = realpath($imagedir.$dir); + + if ($r_imagedir === false || strcmp($r_imagedir, $r_basedir . DIRECTORY_SEPARATOR) !== 0) { + print_r($r_basedir); + print_r($r_imagedir); print "Path Traversal Detected!"; exit(); }