Bug #66033
closedopen_basedir restriction fails File->getContents() due to ResourceStorage->checkFileExtensionPermission() and GeneralUtility::split_fileref()
100%
Description
I have open_basedir restrictions on our servers.
I want to fetch the file content from a FileReference of a local file.
File->getContents()calls
ResourceStorage->getFileContents()which checks
ResourceStorage->assureFileReadPermission()first.
ResourceStorage->checkFileActionPermission()calls
if (!$this->checkFileExtensionPermission($file->getName())) {supplying ONLY the fileName and not the file object or the full path to the file!
In checkFileExtensionPermission() since only the fileName has been supplied extracting the extension is done like this:
$fileInfo = GeneralUtility::split_fileref($fileName); ... $fileExtension = strtolower($fileInfo['fileext']);
GeneralUtility::split_fileref in turn expects to be fed with full pathes to existing files only and happily calls !is_dir($fileref) :
static public function split_fileref($fileref) { if (!is_dir($fileref) && preg_match('/(.*)\\.([^\\.]*$)/', $info['file'], $reg)) {
This results in a check for is_dir() supplying only a file name.
With a open_basedir restriction in effect this results in
PHP Warning: is_dir(): open_basedir restriction in effect. File(XYZ.svg) is not within the allowed path(s): ([...]) in typo3_src-6.2.11/typo3/sysext/core/Classes/Utility/GeneralUtility.php line 886"
since the file XYZ.svg is not directly in one of the configured pathes but a subdirectory "fileadmin/user_upload".
Either the check to fetch the file extension in checkFileExtensionPermission() has to be adapted to fetch differently or GeneralUtility::split_fileref needs to be changed not to use is_dir.
Updated by Frans Saris over 9 years ago
- Status changed from New to Accepted
pathinfo() [1] could be used instead of $fileInfo = GeneralUtility::split_fileref() as it doesn't care if the path exists.
gr. Frans
Updated by Gerrit Code Review over 9 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/38221
Updated by Gerrit Code Review over 9 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/38221
Updated by Gerrit Code Review over 9 years ago
Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/38273
Updated by Frans Saris over 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 05b26eb7699a7e8e2c2dc6968ebb287d3cfa347d.