[IMPORTANT SECURITY] Fix critical directory traversal vulnerability in routing component

This commit is contained in:
Jill Stingray 2020-06-14 18:35:49 +03:00
parent f73c48dd50
commit 3e0637e447
2 changed files with 9 additions and 2 deletions

View file

@ -171,7 +171,7 @@ class Router
if($_SERVER["HTTP_IF_NONE_MATCH"] === $hash)
exit(header("HTTP/1.1 304"));
header("Content-Type: " . system_extension_mime_type($file));
header("Content-Type: " . system_extension_mime_type($file) ?? "text/plain; charset=unknown-8bit");
header("Content-Size: " . filesize($file));
header("ETag: $hash");
@ -252,7 +252,8 @@ class Router
function execute(string $url, ?string $parentModule = null): ?string
{
$this->url = parse_url($url, PHP_URL_PATH);
$this->url = chandler_escape_url(parse_url($url, PHP_URL_PATH));
if(!is_null($parentModule)) {
$GLOBALS["parentModule"] = $parentModule;
$this->scope["parentModule"] = $GLOBALS["parentModule"];

View file

@ -0,0 +1,6 @@
<?php declare(strict_types=1);
function chandler_escape_url(string $url): string
{
return preg_replace("%\.\.\/|\/\.\.%", "", $url);
}