Bug #69356
closedHandling of uploaded files not within open_basedir
100%
Description
When the "upload_tmp_dir" folder is not within the "open_basedir" an Exception will get thrown:
throw new \InvalidArgumentException('File "' . $localFilePath . '" does not exist.', 1319552745);
Because of this line:
The method "addFile()" will get called from "addUploadedFile()": https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/core/Classes/Resource/ResourceStorage.php#l1806
The exception will get thrown because "file_exists()" will return FALSE when called with a file argument outside of open_basedir.
But according to the "move_uploaded_file" PHP manual function description "move_uploaded_file" is aware of "open_basedir" but will only perform checks for the target argument - the source argument (uploaded file) is checked otherwise: http://php.net/manual/en/function.move-uploaded-file.php#refsect1-function.move-uploaded-file-notes
The proper solution would be to use "file_exists()" next to "is_uploaded_file()" or'ed together. Patch will get sent to gerrit.
When trying to reproduce this problem take the following PHP bug into account: https://bugs.php.net/bug.php?id=41824.
So take care that both the "open_base_dir" and the "upload_tmp_dir" reside on the same filesystem - because otherwise the "move_uploaded_file" PHP function will internally not just "rename()" the file (which will bypass source open_basedir restrictions) but will use "php_copy_file()". Please also note that only PHP 4.4.3 and later will be affected (So also all 5.x versions)
Updated by Gerrit Code Review over 8 years ago
- Status changed from New 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/42888
Updated by Gerrit Code Review over 8 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/42888
Updated by Gerrit Code Review over 8 years ago
Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/42888
Updated by Mathias Schreiber over 8 years ago
- Target version deleted (
next-patchlevel)
Updated by Gerrit Code Review over 8 years ago
Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/42888
Updated by Gerrit Code Review over 8 years ago
Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/42888
Updated by Gerrit Code Review over 8 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 https://review.typo3.org/44710
Updated by Anonymous over 8 years ago
- Status changed from Under Review to Resolved
- % Done changed from 50 to 100
Applied in changeset 519df71b08a5fba2a76cb73107c043e0f4686281.