Skip to content

Commit

Permalink
Improve asset file path handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Towers committed Mar 31, 2020
1 parent a9b4a5b commit 2b8939c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/cms/classes/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,14 @@ public function getFilePath($fileName = null)
$fileName = $this->fileName;
}

return $this->theme->getPath().'/'.$this->dirName.'/'.$fileName;
// Limit paths to those under the assets directory
$directory = $this->theme->getPath() . '/' . $this->dirName . '/';
$path = realpath($directory . $fileName);
if (!starts_with($path, $directory)) {
return false;
}

return $path;
}

/**
Expand Down

0 comments on commit 2b8939c

Please sign in to comment.