Skip to content

Commit 2b8939c

Browse files
author
Luke Towers
committed
Improve asset file path handling
1 parent a9b4a5b commit 2b8939c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

modules/cms/classes/Asset.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,14 @@ public function getFilePath($fileName = null)
285285
$fileName = $this->fileName;
286286
}
287287

288-
return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName;
288+
// Limit paths to those under the assets directory
289+
$directory = $this->theme->getPath() . '/' . $this->dirName . '/';
290+
$path = realpath($directory . $fileName);
291+
if (!starts_with($path, $directory)) {
292+
return false;
293+
}
294+
295+
return $path;
289296
}
290297

291298
/**

0 commit comments

Comments
 (0)