Skip to content

Commit

Permalink
[CVE-2020-9309] Require MimeUploadValidator on userformis' File Uploa…
Browse files Browse the repository at this point in the history
…d field
  • Loading branch information
Maxime Rainville authored and dnsl48 committed Jul 13, 2020
1 parent c0c4698 commit d459c51
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions _config/mimevalidator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
Name: mimeuploadvalidator-userforms
---
SilverStripe\Core\Injector\Injector:
SilverStripe\Assets\Upload_Validator.userforms:
class: SilverStripe\MimeValidator\MimeUploadValidator
7 changes: 6 additions & 1 deletion code/Model/EditableFormField/EditableFileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

use SilverStripe\Assets\File;
use SilverStripe\Assets\Folder;
use SilverStripe\Assets\Upload_Validator;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Convert;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\FileField;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\NumericField;
use SilverStripe\Forms\TreeDropdownField;
Expand Down Expand Up @@ -192,11 +194,14 @@ public function validate()
return $result;
}



public function getFormField()
{
$field = FileField::create($this->Name, $this->Title ?: false)
->setFieldHolderTemplate(EditableFormField::class . '_holder')
->setTemplate(__CLASS__);
->setTemplate(__CLASS__)
->setValidator(Injector::inst()->get(Upload_Validator::class . '.userforms'));

$field->setFieldHolderTemplate(EditableFormField::class . '_holder')
->setTemplate(__CLASS__);
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"silverstripe/cms": "^4.6",
"symbiote/silverstripe-gridfieldextensions": "^3.1",
"silverstripe/segment-field": "^2.0",
"silverstripe/versioned": "^1.0"
"silverstripe/versioned": "^1.0",
"silverstripe/mimevalidator": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7",
Expand Down

0 comments on commit d459c51

Please sign in to comment.