After installing the SUPEE 7405 patch, we noticed a problem uploading images from the admin. All file permissions are being set to CHMOD 640 which makes them inaccessible to all users.
Is there a solution that does not involve rewriting the /lib/Varien/File/Uploader.php file?
Please go on this file
and just change line no 220 and change
chmod($destinationFile, 0640)
tochmod($destinationFile, 0644)
It's working.
Look at this: https://community.magento.com/t5/Security-Patches/after-installing-SUPEE-7405-can-no-longer-add-or-change-images/td-p/26785/page/3
Changing Upload.php code worked for all my installtions.
The accepted answer is a good solution.
If you are unable to change the ownership (maybe because you are on a shared server) you can run cron jobs to change file permission on the newly uploaded files.
A new version of SUPEE-7405 has been released that resolves this issue:
http://magento.com/security/patches/supee-7405
Note that even without the revised patch, you can fix the issue by using the recommended file permissions (see below).
Magento expects the webserver to own the site files:
http://devdocs.magento.com/guides/m1x/install/installer-privileges_after.html#privs-after
You can resolve this problem by making the webserver the owner of the files.
The webserver user name is commonly
www-data
orapache
.If you follow the instructions in the above link, the webserver will have read access to all files, and write access to media files and var files. This should be all you need for typical site operation. If you need to use Magento Connect you'll have to temporarily give the webserver write access to all files.
Only the webserver user needs access to the files. There is no need to grant any permissions to all users.
You may want to grant access to a specific user if, for example, you need to edit or upload files via FTP. In this case, what I do is set a user who owns the file system and set the files' group to the webserver:
The above commands will give your file system owner read/write access to everything and the webserver read access to everything. The webserver will also be able to write to the media and var directories.
We've solved the issue for our environments, however, I'm not sure how much help this will be for everyone else. Even though I'm not a network engineer, I will try to explain it. If enough people find this post helpful, I'll mark it as correct. Also, please note that even though the issue arose from Magento's SUPEE 7405 patch, the solution is Network based, not code based.
I believe the purpose of the chmod alteration in the patch was to prevent hackers from hijacking your images and storing sensitive data within them (the checkout header image hack for example). To prevent this hack, they limit all access to uploaded files/images via chmod 640.
With that said...
The latest patch to Magento 1.X seems to require an environment configuration change. As one of our network engineers said, they assume we are using Apache with mod_php, which reads and writes all files as the Apache user. However, if you are using fcgi or suphp, the files would be written as the domain user. Depending on your environment, you may need to add Apache to your groups and allow it to read the files.
Try the chown -R solution first, and if that doesn't work you may need to contact your host or add Apache to your "groups" so that it has owner access.