Technical resource
How to install SUPEE-9767 without SSH
Note: This is a historical reference, not a current security baseline. Magento 1 is end-of-life.
July 12, 2017: Community Edition 1.9.3.4 and SUPEE-9767 version 2 patch address customer registration and other issues encountered by some merchants when using the original release or patch.
If you have SSH access, please refer to how to apply the patch via SSH.
If you have no SSH access to apply the patch, you can simply upgrade to the latest Magento 1 version or OpenMage LTS with all the latest security patches up to date (it is about ~30 patches up to 2021). If Magento upgrade or migration to Openmage is not possible due to some reason, you can still can apply the patch via FTP/sFTP upload as shown in this article.
If you wish to save time and have us to install these patches for you, simply click here to order installation.
Preparations
- Disable Magento Compiler and clear compiler cache
- Disable Symlinks setting
In Magento backend navigate to System > Configuration > Advanced > Developer > Template Settings > Enable Symlinks and set it to No, if it is not set already:
Applying Magento patches via FTP/sFTP or FileManager / File Upload
To apply patches in this way we simply replace changed files. This way can not be used blindly if you or your developers have changed any core Magento files (which is a big no-no, by the way). Such changes should be re-applied to patched files, or you loose these changes.Note: Make sure, that all previous patches including SUPEE-5344, SUPEE-5994, SUPEE-6285, SUPEE-6788, SUPEE-7405 and SUPEE-8788 are applied as this patch should be applied on top of all previous patches.
Note: If you previously applied SUPEE-9767v1 (first version of this patch released on May 31, 2017) to apply new SUPEE-9767v2 version you can simply upload SUPEE-9767v2 files on top of it, it will replace all files from version 1The following files are changed by SUPEE-9767 (version 2 for 1.9.3.2 released on July 12, 2017):
app/code/core/Mage/Admin/Model/Session.php app/code/core/Mage/Adminhtml/Block/Checkout/Formkey.php app/code/core/Mage/Adminhtml/Block/Notification/Symlink.php app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Filter/Date.php app/code/core/Mage/Adminhtml/Model/Config/Data.php app/code/core/Mage/Adminhtml/Model/System/Config/Backend/Symlink.php app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php app/code/core/Mage/Checkout/controllers/MultishippingController.php app/code/core/Mage/Checkout/controllers/OnepageController.php app/code/core/Mage/Checkout/etc/system.xml app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php app/code/core/Mage/Core/Controller/Front/Action.php app/code/core/Mage/Core/Controller/Request/Http.php app/code/core/Mage/Core/Model/File/Validator/Image.php app/code/core/Mage/Core/etc/config.xml app/code/core/Mage/Core/etc/system.xml app/code/core/Mage/Core/sql/core_setup/upgrade-1.6.0.6.1.1-1.6.0.6.1.2.php app/code/core/Mage/Dataflow/Model/Convert/Adapter/Zend/Cache.php app/code/core/Mage/Dataflow/Model/Convert/Container/Abstract.php app/code/core/Mage/Dataflow/Model/Convert/Parser/Csv.php app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php app/code/core/Mage/ImportExport/Model/Import/Uploader.php app/code/core/Mage/Sales/Model/Quote/Item.php app/code/core/Mage/Widget/Model/Widget/Instance.php app/code/core/Mage/XmlConnect/Helper/Image.php app/code/core/Mage/XmlConnect/controllers/Adminhtml/MobileController.php app/design/adminhtml/default/default/layout/main.xml app/design/adminhtml/default/default/template/notification/formkey.phtml app/design/adminhtml/default/default/template/notification/symlink.phtml app/design/adminhtml/default/default/template/oauth/authorize/head-simple.phtml app/design/adminhtml/default/default/template/page/head.phtml app/design/frontend/base/default/template/checkout/cart/shipping.phtml app/design/frontend/base/default/template/checkout/multishipping/addresses.phtml app/design/frontend/base/default/template/checkout/multishipping/billing.phtml app/design/frontend/base/default/template/checkout/multishipping/shipping.phtml app/design/frontend/base/default/template/checkout/onepage/billing.phtml app/design/frontend/base/default/template/checkout/onepage/payment.phtml app/design/frontend/base/default/template/checkout/onepage/shipping.phtml app/design/frontend/base/default/template/checkout/onepage/shipping_method.phtml app/design/frontend/base/default/template/persistent/checkout/onepage/billing.phtml app/design/frontend/rwd/default/layout/page.xml app/design/frontend/rwd/default/template/checkout/cart/shipping.phtml app/design/frontend/rwd/default/template/checkout/multishipping/addresses.phtml app/design/frontend/rwd/default/template/checkout/multishipping/billing.phtml app/design/frontend/rwd/default/template/checkout/onepage/payment.phtml app/design/frontend/rwd/default/template/checkout/onepage/shipping.phtml app/design/frontend/rwd/default/template/persistent/checkout/onepage/billing.phtml app/etc/config.xml app/locale/en_US/Mage_Adminhtml.csv app/locale/en_US/Mage_Core.csv app/locale/en_US/Mage_Dataflow.csv app/locale/en_US/Mage_XmlConnect.csv downloader/Maged/Connect.php downloader/Maged/Controller.php downloader/Maged/Model/Session.php js/lib/jquery/jquery-1.12.0.js js/lib/jquery/jquery-1.12.0.min.js js/lib/jquery/jquery-1.12.0.min.map js/varien/payment.js skin/frontend/base/default/js/opcheckout.jsTo install the patch via FTP/File Upload
- select patch bundle archive corresponding to your Magento version from the table below and unpack it
- upload all files and folders to Magento root directory of your store, replacing all files
| Magento version | SUPEE-9767v2 |
|---|---|
| 1.9.3.3 | SUPEE-9767v2-1.9.3.3 |
| 1.9.3.2 | SUPEE-9767v2-1.9.3.2 |
| 1.9.3.1 | SUPEE-9767v2-1.9.3.1 |
| 1.9.3.0 | SUPEE-9767v2-1.9.3.0 |
| 1.9.2.4 | SUPEE-9767v2-1.9.2.4 |
| 1.9.2.3 | SUPEE-9767v2-1.9.2.3 |
| 1.9.2.2 | SUPEE-9767v2-1.9.2.2 |
| 1.9.2.1 | SUPEE-9767v2-1.9.2.1 |
| 1.9.2.0 | SUPEE-9767v2-1.9.2.0 |
| 1.9.1.1 | SUPEE-9767v2-1.9.1.1 |
| 1.9.1.0 | SUPEE-9767v2-1.9.1.0 |
| 1.8.1.0 | SUPEE-9767v2-1.8.1.0 |
| 1.7.0.2 | SUPEE-9767v2-1.7.0.2 |
Enable Form Key Validation On Checkout (optional)
To take all advantages of SUPEE-9767 patch it is recommended to enable form key verification for checkout at System > Configuration > Advanced > Admin > Security > Enable Form Key Validation On Checkout.Note: Check with your theme developer if your theme is compatible before enabling that option as it can break checkout process. Make sure that corresponding checkout template phtml files in your custom theme have form key fields included and custom opcheckout.js is updated.These fields were added in this patch into default themes, so if you use default theme (base / rwd) or your theme does not override checkout pages, then you can enable Form Key Validation On Checkout right away. Otherwise, check with your theme developer if your theme is compatible before enabling that option as it can break checkout process. The following template files in your custom theme should be checked:
template/checkout/cart/shipping.phtml template/checkout/multishipping/billing.phtml template/checkout/multishipping/shipping.phtml template/checkout/multishipping/addresses.phtml template/checkout/onepage/billing.phtml template/checkout/onepage/payment.phtml template/checkout/onepage/shipping.phtml template/checkout/onepage/shipping_method.phtml template/persistent/checkout/onepage/billing.phtmlThese files should include formkey line and you can add it just like in default template files:
--- app/design/frontend/base/default/template/checkout/onepage/payment.phtml +++ app/design/frontend/base/default/template/checkout/onepage/payment.phtml @@ -35,6 +35,7 @@Other set of files to update are custom javascript files that overridejs/varien/payment.jsandskin/frontend/base/default/js/opcheckout.js. These javascript files should be updated with the following:@@ -711,7 +711,7 @@ Payment.prototype = { } var method = null; for (var i=0; iVerification and flush of Magento PHP opcode cache
Flush Magento caches: Navigate in Magento backend to System > Cache Management and flush Magento cache and CSS/JS caches. If you use PHP opcode caches (OPCache/APC/XCache/eAccelerator) make sure to flush it after patching (or restart webserver), otherwise code will continue to run from caches. Test that your store is working. Test Checkout process. If you have any difficulties with applying the patches please let us know in comments, so we can find the solution together.
Comments
Archived discussion
Hello - can you please upload the fix for magento 1.6.2 ? and a question - do I need all other patches BEFORE using this one? Or is this an “independent” patch ?
thank you very much for your service!
Thank you as always for the non-SSH patch installation help. This one seemed to go ok, however there is now this notice in the backend: “Formkey validation on checkout disabled. This may expose security risks. We strongly recommend to Enable Form Key Validation On Checkout in Admin / Security Section, for protect your own checkout process.”
I get the feeling if I enable that in settings it might break our checkout process (did some googling), but if I don’t there may be a bigger security risk than what we just patched? Is it usual to set this after installing SUPEE-9767? Thanks again.
It is safe to enable this option with default theme (rwd or base theme) or with any new theme that have form keys in checkout forms. If custom theme have no form_key inputs in checkout forms, it will be impossible to submit form / proceed with checkout as Magento will ignore any input from checkout without form keys. Patching custom theme is straightforward task, it is required to add form keys input (one line) in the following theme files (for 1.9.x): template/checkout/cart/shipping.phtml template/checkout/multishipping/billing.phtml template/checkout/multishipping/shipping.phtml template/checkout/multishipping/addresses.phtml template/checkout/onepage/billing.phtml template/checkout/onepage/payment.phtml template/checkout/onepage/shipping.phtml template/checkout/onepage/shipping_method.phtml template/persistent/checkout/onepage/billing.phtml
If some files do not exist in the theme, it will use default ones, that are already patched by default.
The option is created to protect from CSRF: Checkout functionality is vulnerable to cross-site request forgery attacks. These types of attacks are typically executed by phishing emails or pages that allow attackers to modify or harvest payment details.
The line to add into template files is usually like the following:
getBlockHtml('formkey') ?>How about the theme files locations for 1.7.0.2? Thanks again Magentary.
Also - if I enable Form Key Validation to test if checkout process works, and it then doesn’t work, will disabling that setting then allow it to work again til I input the fix? Thanks.
Yes, sure, it is possible to disable Form Key Validation for checkout again and it will work just like it was always disabled.
For 1.7.0.2 the list of files is without addresses.phtml template: template/checkout/cart/shipping.phtml template/checkout/multishipping/billing.phtml template/checkout/multishipping/shipping.phtml template/checkout/onepage/billing.phtml template/checkout/onepage/payment.phtml template/checkout/onepage/shipping.phtml template/checkout/onepage/shipping_method.phtml template/persistent/checkout/onepage/billing.phtml
You can see the list of template files patched in app/etc/applied.patches.list file when patch is applied.
i have updated SUPEE-9767 patch in CE 1.9.3.2 through FTP. Everything works fine, except the confirmation mail for new account and new order. I m getting mail for “forget password” but not for new confirmation mail. But new account and orders are successfully updated in backend. Could you help me how could i trace and fix?
Thank you
Confirmation mails are working now. just changed the app/code/core/Mage/Core/Model/Email/Template.php template.php (line number:424) from : if ($this->hasQueue() && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) {
to: if (!($this->hasQueue()) && $this->getQueue() instanceof Mage_Core_Model_Email_Queue) {
So riddle me this…. I have uploaded all the new files in MY theme files and of course as well as the default just for the heck of it. When I log in to the backed of my store like I should I see up on the top the message “Important: Formkey validation on checkout disabled. This may expose security risks. We strongly recommend to Enable Form Key Validation On Checkout in Admin / Security Section, for protect your own checkout process.” Now when I go to the area to “Enable” this I don’t even see it there? What in the heck am I missing? I have ran my store through MageReport and it shows the Patch 9767 is installed so I would imagine I did all of it right. Any insight on this would be greatly appreciated. Thanks!
P.S. I am running Magento 1.9.2.2 if that matters at all.
@magentary:disqus I think for the version 1.9.2.2, you guys missed to add changes to this file “app/code/core/Mage/Customer/Model/Session.php”
diff –git app/code/core/Mage/Customer/Model/Session.php app/code/core/Mage/Customer/Model/Session.php index 623fa39..b5e5eda 100644 — app/code/core/Mage/Customer/Model/Session.php +++ app/code/core/Mage/Customer/Model/Session.php @@ -222,6 +222,7 @@ class Mage_Customer_Model_Session extends Mage_Core_Model_Session_Abstract { $this->setCustomer($customer); $this->renewSession();
Let me know if I am wrong!
okay I see, you should change this line in your blog “The following files are changed by SUPEE-9767 (v1 relased on May 31, 2017):” and should include also “app/code/core/Mage/Customer/Model/Session.php”
While verifying, I made a mistake.
app/code/core/Mage/Core/Model/File/Validator/Image.php
public function validate($filePath) { list($imageWidth, $imageHeight, $fileType) = getimagesize($filePath); if ($fileType) { if ($this->isImageType($fileType)) { //replace tmp image with re-sampled copy to exclude images with malicious data $image = imagecreatefromstring(file_get_contents($filePath)); if ($image !== false) { $img = imagecreatetruecolor($imageWidth, $imageHeight); imagecopyresampled($img, $image, 0, 0, 0, 0, $imageWidth, $imageHeight, $imageWidth, $imageHeight); switch ($fileType) { case IMAGETYPE_GIF: imagegif($img, $filePath); break; case IMAGETYPE_JPEG: imagejpeg($img, $filePath, 100); break; case IMAGETYPE_PNG: imagepng($img, $filePath); break; default: return; } imagedestroy($img); imagedestroy($image); return null; } else { throw Mage::exception(‘Mage_Core’, Mage::helper(‘core’)->(‘Invalid image.’)); } } } throw Mage::exception(‘Mage_Core’, Mage::helper(‘core’)->(‘Invalid MIME type.’)); }
Change to
public function validate($filePath) { $fileInfo = getimagesize($filePath); if (is_array($fileInfo) and isset($fileInfo[2])) { if ($this->isImageType($fileInfo[2])) { return null; } } throw Mage::exception(‘Mage_Core’, Mage::helper(‘core’)->__(‘Invalid MIME type.’)); }
After upload the SUPEE-9767 in 1.8.1.0, I am getting below error:- Fatal error: Call to a member function getRedirectUrl() on a non-object in /app/code/core/Mage/Admin/Model/Session.php on line 130 when you refresh again on this stage, you can able to see the dashboard.
if any one have idea please share.
After installing the patch, we started getting the error below when the customer logs out of their account.
Invalid method Mage_Core_Model_Session::renewFormKey(Array ( ) )
Trace: #0 /app/code/core/Mage/Customer/Model/Session.php(311): Varien_Object->__call(‘renewFormKey’, Array) #1 app/code/core/Mage/Customer/Model/Session.php(311): Mage_Core_Model_Session->renewFormKey() #2 app/code/core/Mage/Customer/Model/Session.php(255): Mage_Customer_Model_Session->_logout() #3 /app/code/core/Mage/Customer/controllers/AccountController.php(236): Mage_Customer_Model_Session->logout() #4 /app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Customer_AccountController->logoutAction() #5 /app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch(’logout’) #6 /app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #7 /app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch() #8 /app/Mage.php(1367): Mage_Core_Model_App->run(Array) #9 /index.php(84): Mage::run(’’, ‘store’) #10 {main}
There are two possible causes of this error:
To solve it, corresponding override should be patched as well with adding renewFormKey method and OPcode cache should be flushed.