mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-02 19:36:08 +01:00
Return 401 unauthorized and exit if trying to access a file outside the backups folder
This commit is contained in:
@@ -622,7 +622,15 @@ class AdminController
|
|||||||
$download = $this->grav['uri']->param('download');
|
$download = $this->grav['uri']->param('download');
|
||||||
|
|
||||||
if ($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));
|
$log = JsonFile::instance($this->grav['locator']->findResource("log://backup.log", true, true));
|
||||||
|
|||||||
Reference in New Issue
Block a user