-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-31040: Remote Code Execution in file uploads
- Loading branch information
Showing
6 changed files
with
168 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
/** | ||
* File containing the eZFileExtensionBlackListValidator class. | ||
* | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
* @version //autogentag// | ||
* @package lib | ||
*/ | ||
|
||
/*! | ||
\class eZFileExtensionBlackListValidator ezfileextensionblacklistvalidator.php | ||
\brief The class eZFileExtensionBlackListValidator validates file extensions based on a blacklist. | ||
*/ | ||
|
||
class eZFileExtensionBlackListValidator extends eZInputValidator | ||
{ | ||
/*! | ||
Constructor | ||
*/ | ||
function __construct() | ||
{ | ||
parent::eZInputValidator(); | ||
|
||
$fileIni = eZINI::instance('file.ini'); | ||
$this->constraints['extensionsBlackList'] = $fileIni->variable('FileSettings','FileExtensionBlackList'); | ||
} | ||
|
||
/*! | ||
Tries to validate to the filename \a $filename and returns one of the validator states | ||
eZInputValidator::STATE_ACCEPTED, eZInputValidator::STATE_INTERMEDIATE or | ||
eZInputValidator::STATE_INVALID. | ||
*/ | ||
function validate( $filename ) | ||
{ | ||
if ( | ||
pathinfo($filename, PATHINFO_BASENAME) !== $filename || | ||
in_array(strtolower(pathinfo($filename, PATHINFO_EXTENSION)), $this->constraints['extensionsBlackList'], true) | ||
) { | ||
return eZInputValidator::STATE_INVALID; | ||
} | ||
|
||
return eZInputValidator::STATE_ACCEPTED; | ||
} | ||
|
||
/*! | ||
Return the list of blacklisted file extensions. | ||
*/ | ||
function extensionsBlackList() | ||
{ | ||
return $this->constraints['extensionsBlackList']; | ||
} | ||
|
||
/// \privatesection | ||
protected $constraints = array( | ||
'extensionsBlackList' => array(), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters