[IMPORTANT SECURITY] Fix critical directory traversal vulnerability in file seeding mechanism

This commit is contained in:
Jill Stingray 2020-06-14 18:43:23 +03:00
parent 02dd373460
commit cf6cda260d

View file

@ -17,6 +17,7 @@ final class BlobPresenter extends OpenVKPresenter
function renderFile(/*string*/ $dir, string $name, string $format)
{
$dir = $this->getDirName($dir);
$name = preg_replace("%[^a-zA-Z0-9_\-]++%", "", $name);
$path = OPENVK_ROOT . "/storage/$dir/$name.$format";
if(!file_exists($path)) {
$this->notFound();