Bug 498031 - php function move_uploaded_file ignores umask setting
Summary: php function move_uploaded_file ignores umask setting
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: php
Version: 5.3
Hardware: All
OS: Linux
low
medium
Target Milestone: rc
: ---
Assignee: Joe Orton
QA Contact: BaseOS QE
URL: http://bugs.php.net/bug.php?id=42291
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2009-04-28 15:17 UTC by info@kobaltwit.be
Modified: 2010-03-30 08:24 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-03-30 08:24:47 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Fix for the move_uploaded_file umask issue (974 bytes, patch)
2009-04-28 15:26 UTC, info@kobaltwit.be
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
PHP Bug Tracker 42291 0 None None None Never
Red Hat Product Errata RHBA-2010:0241 0 normal SHIPPED_LIVE php bug fix and enhancement update 2010-03-29 13:30:16 UTC

Description info@kobaltwit.be 2009-04-28 15:17:33 UTC
Description of problem:
The php function move_uploaded_file generates inconsistent destination file permissions, depending on how the file is moved: if the source and destination path are on the same filesystem, the file is moved. If the paths are on different filesystems, the file is copied. Note, this is a php internal decision, not something a user can influence in any way.
If the file is moved, the destination file will always have 0600 as permissions.
If it's copied, the destination file's permissions will be determined by the active umask (default 0022, so default file permissions are 0644).

The proper behaviour would be that the destination file's permissions are always determined by the active umask.

This bug is mostly apparent in shared hosting environments running a php based webapplication. Examples of affected applications are drupal and joomla. These applications use php to upload a file that should later be accessed by the httpd server. Due to the 0600 permissions, this won't always work.

For more details, see the original bugreport on the php bugtracker:
http://bugs.php.net/bug.php?id=42291

Version-Release number of selected component (if applicable):
5.1.6

How reproducible:
Always

Steps to Reproduce:
1. Install one of the affected webapplications on a webserver
2. Use the application to upload a file
3. Login to the server, and observe that the uploaded file has got 0600 file permissions even though the umask would allow more liberal permissions. (Of course, only if the upload tmp dir is on the same file system than the final destination)
  
Actual results:
Depending on the rest of the setup, this file will not be accessible by httpd.

Expected results:
The permissions of the uploaded file should obey the umask.

Additional info:
php developers have acknowleged this bug and fixed it in a later release of php. The original bugreport indicates that this was fixed in at least 5.2.7.

Comment 1 info@kobaltwit.be 2009-04-28 15:26:32 UTC
Created attachment 341588 [details]
Fix for the move_uploaded_file umask issue

I have dug in the php cvs repository and found that this issue was fixed in cvs in
ext/standard/basic_functions.c, revision 1.818.

I have taken the changes there and reworked them to be compatible with redhat's version of php 5.1.6.

The attached patch should fix the problem for RHEL5.3.

Comment 2 Joe Orton 2009-10-13 13:51:26 UTC
Thanks for reporting and extracting the fix!

Comment 4 Joe Orton 2009-12-16 12:42:52 UTC
I've made test packages available which should fix this issue.  These
packages are unsupported, have not been through the standard Red Hat
QA process, and are not recommended for use on production systems.

   http://people.redhat.com/~jorton/Tikanga-php/

Use of these packages may prevent you from (automatically) upgrading
to any asynchronous security errata which are issued before the
release of RHEL 5.5 due to version mismatches.

Please record any feedback on use of these test packages (positive or
negative!) on this bug report.

Comment 8 errata-xmlrpc 2010-03-30 08:24:47 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2010-0241.html


Note You need to log in before you can comment on or make changes to this bug.