Skip to content

Commit

Permalink
[TASK] Harden internal state handling
Browse files Browse the repository at this point in the history
Internal components using `unserialize` are enforced to disallow
classes in their internal state representation. This is a preparation
for starting with RIPS scanner.

Resolves: #91571
Releases: master, 10.4, 9.5
Change-Id: I3a5026e34a381e79817b46025d81083b2bc5b290
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/64779
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Frank Nägler <frank.naegler@typo3.org>
Reviewed-by: Frank Nägler <frank.naegler@typo3.org>
  • Loading branch information
ohader authored and NeoBlack committed Jun 5, 2020
1 parent abc757f commit d5e7f85
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions typo3/sysext/core/Classes/Charset/CharsetConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ protected function initCharset($charset)
// Caching brought parsing time for gb2312 down from 2400 ms to 150 ms. For other charsets we are talking 11 ms down to zero.
$cacheFile = Environment::getVarPath() . '/charset/charset_' . $charset . '.tbl';
if ($cacheFile && @is_file($cacheFile)) {
$this->parsedCharsets[$charset] = unserialize(file_get_contents($cacheFile));
$this->parsedCharsets[$charset] = unserialize(file_get_contents($cacheFile), ['allowed_classes' => false]);
} else {
// Parse conversion table into lines:
$lines = GeneralUtility::trimExplode(LF, file_get_contents($charsetConvTableFile), true);
Expand Down Expand Up @@ -495,7 +495,7 @@ protected function initUnicodeData()
}
// Use cached version if possible
if ($cacheFileASCII && @is_file($cacheFileASCII)) {
$this->toASCII['utf-8'] = unserialize(file_get_contents($cacheFileASCII));
$this->toASCII['utf-8'] = unserialize(file_get_contents($cacheFileASCII), ['allowed_classes' => false]);
return 2;
}
// Process main Unicode data file
Expand Down Expand Up @@ -657,7 +657,7 @@ protected function initToASCII($charset)
// Use cached version if possible
$cacheFile = Environment::getVarPath() . '/charset/csascii_' . $charset . '.tbl';
if ($cacheFile && @is_file($cacheFile)) {
$this->toASCII[$charset] = unserialize(file_get_contents($cacheFile));
$this->toASCII[$charset] = unserialize(file_get_contents($cacheFile), ['allowed_classes' => false]);
return 2;
}
// Init UTF-8 conversion for this charset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function createDomainObject(array $databaseRow)
$originalFile = $this->factory->getFileObject((int)$databaseRow['original']);
$originalFile->setStorage($this->factory->getStorageObject($originalFile->getProperty('storage')));
$taskType = $databaseRow['task_type'];
$configuration = unserialize($databaseRow['configuration']);
$configuration = unserialize($databaseRow['configuration'], ['allowed_classes' => false]);

return GeneralUtility::makeInstance(
$this->objectType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ protected function parseSub(array &$setup)
}
// unserialize(serialize(...)) may look stupid but is needed because of some reference issues.
// See forge issue #76919 and functional test hasFlakyReferences()
$this->setVal($objStrName, $setup, unserialize(serialize($res)), 1);
$this->setVal($objStrName, $setup, unserialize(serialize($res), ['allowed_classes' => false]), 1);
break;
case '>':
if ($this->syntaxHighLight) {
Expand Down

0 comments on commit d5e7f85

Please sign in to comment.