Skip to content

Commit

Permalink
Prevent uploading php files in assets manager
Browse files Browse the repository at this point in the history
  • Loading branch information
aheinze committed Mar 10, 2023
1 parent 69ec57c commit becca80
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Release Notes

## WIP

- Prevent uploading php files in assets manager

## 2.4.0 (2023-03-08)

- Add additional security check editing php files in finder
Expand Down
5 changes: 5 additions & 0 deletions modules/Assets/bootstrap.php
Expand Up @@ -80,6 +80,11 @@
$_isAllowed = $allowed === true ? true : preg_match("/\.({$allowed})$/i", $_file);
$_sizeAllowed = $max_size ? filesize($files['tmp_name'][$i]) < $max_size : true;

// prevent uploading php files
if ($_isAllowed && pathinfo($_file, PATHINFO_EXTENSION) === 'php') {
$_isAllowed = false;
}

if (!$files['error'][$i] && $_isAllowed && $_sizeAllowed && move_uploaded_file($files['tmp_name'][$i], $_file)) {

$_files[] = $_file;
Expand Down

0 comments on commit becca80

Please sign in to comment.