diff --git a/dashboard/pgs/class.reflector.php b/dashboard/pgs/class.reflector.php index 1dd4931..4dadf23 100644 --- a/dashboard/pgs/class.reflector.php +++ b/dashboard/pgs/class.reflector.php @@ -149,28 +149,13 @@ class xReflector { } public function SetFlagFile($Flagfile) { - // Prevent path traversal - get the real path + // Security: Only allow country.csv from the pgs directory + $expectedFile = dirname(__FILE__) . '/country.csv'; $realPath = realpath($Flagfile); - // If realpath fails, the file doesn't exist - if ($realPath === false) { - error_log("Flag file does not exist: " . $Flagfile); - return false; - } - - // Security: Ensure it's the country.csv file we expect - if (basename($realPath) !== 'country.csv') { - error_log("Flag file must be country.csv, got: " . basename($realPath)); - return false; - } - - // Security: Ensure the file is in the same directory as this class file or subdirectory - $thisDir = dirname(__FILE__); // Gets /path/to/pgs - $thisDirReal = realpath($thisDir); - - // The flag file must be in the same directory as this class - if (dirname($realPath) !== $thisDirReal) { - error_log("Flag file must be in the same directory as class files. Expected: " . $thisDirReal . ", Got: " . dirname($realPath)); + // Must resolve to the exact expected file + if ($realPath !== $expectedFile) { + error_log("Flag file must be country.csv in pgs directory. Expected: " . $expectedFile . ", Got: " . $realPath); return false; }