Skip to content

Commit

Permalink
add additional security check for uploading files
Browse files Browse the repository at this point in the history
  • Loading branch information
aheinze committed Mar 17, 2023
1 parent ae97fc8 commit 984ef9a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/Assets/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
$_sizeAllowed = $max_size ? filesize($files['tmp_name'][$i]) < $max_size : true;

// prevent uploading php files
if ($_isAllowed && pathinfo($_file, PATHINFO_EXTENSION) === 'php') {
if ($_isAllowed && in_array(strtolower(pathinfo($_file, PATHINFO_EXTENSION)), ['php', 'phar', 'phtml'])) {
$_isAllowed = false;
}

Expand Down
2 changes: 1 addition & 1 deletion modules/Finder/Controller/Finder.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ protected function _isFileTypeAllowed($file) {

$allowed = trim($this->app->retrieve('finder.allowed_uploads', '*'));

if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php' && !$this->helper('acl')->isSuperAdmin()) {
if (in_array(strtolower(pathinfo($file, PATHINFO_EXTENSION)), ['php', 'phar', 'phtml']) && !$this->helper('acl')->isSuperAdmin()) {
return false;
}

Expand Down

0 comments on commit 984ef9a

Please sign in to comment.