Merge pull request from GHSA-5p3f-rh28-8frw
Only serve existing static library assets, really!?
This commit is contained in:
commit
b7c31eb922
|
@ -39,10 +39,21 @@ class StaticController
|
||||||
}
|
}
|
||||||
|
|
||||||
$assetRoot = $library->getStaticAssetPath();
|
$assetRoot = $library->getStaticAssetPath();
|
||||||
$filePath = $assetRoot . DIRECTORY_SEPARATOR . $assetPath;
|
if (empty($assetRoot)) {
|
||||||
|
$app->getResponse()
|
||||||
|
->setHttpResponseCode(404);
|
||||||
|
|
||||||
// Doesn't use realpath as it isn't supposed to access files outside asset/static
|
return;
|
||||||
if (! is_readable($filePath) || ! is_file($filePath)) {
|
}
|
||||||
|
|
||||||
|
$filePath = $assetRoot . DIRECTORY_SEPARATOR . $assetPath;
|
||||||
|
$dirPath = realpath(dirname($filePath)); // dirname, because the file may be a link
|
||||||
|
|
||||||
|
if (
|
||||||
|
$dirPath === false
|
||||||
|
|| substr($dirPath, 0, strlen($assetRoot)) !== $assetRoot
|
||||||
|
|| ! is_file($filePath)
|
||||||
|
) {
|
||||||
$app->getResponse()
|
$app->getResponse()
|
||||||
->setHttpResponseCode(404);
|
->setHttpResponseCode(404);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue