Return 401 unauthorized and exit if trying to access a file outside the backups folder

This commit is contained in:
Flavio Copes
2016-04-08 10:49:59 +02:00
parent f81f21e0ae
commit 9da5f5595a

View File

@@ -622,7 +622,15 @@ class AdminController
$download = $this->grav['uri']->param('download');
if ($download) {
Utils::download(base64_decode(urldecode($download)), true);
$file = base64_decode(urldecode($download));
$backups_root_dir = $this->grav['locator']->findResource('backup://', true);
if (substr($file, 0, strlen($backups_root_dir)) !== $backups_root_dir) {
header('HTTP/1.1 401 Unauthorized');
exit();
}
Utils::download($file, true);
}
$log = JsonFile::instance($this->grav['locator']->findResource("log://backup.log", true, true));