Project

General

Profile

Actions

Bug #69356

closed

Handling of uploaded files not within open_basedir

Added by Bernhard Kraft over 8 years ago. Updated over 5 years ago.

Status:
Closed
Priority:
Should have
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2015-08-27
Due date:
% Done:

100%

Estimated time:
2.00 h
TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

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:

https://git.typo3.org/Packages/TYPO3.CMS.git/blob/HEAD:/typo3/sysext/core/Classes/Resource/ResourceStorage.php#l1100

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)

Actions #1

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

Actions #2

Updated by Markus Sommer over 8 years ago

  • Assignee set to Bernhard Kraft
Actions #3

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

Actions #4

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

Actions #5

Updated by Mathias Schreiber over 8 years ago

  • Target version deleted (next-patchlevel)
Actions #6

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

Actions #7

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

Actions #8

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

Actions #9

Updated by Anonymous over 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 50 to 100
Actions #10

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF