Magento 1的新安全补丁已发布,解决了13个APPSEC问题
https://magento.com/security/patches/supee-10266
应用此修补程序时,您需要注意哪些常见问题?
SUPEE-10266,Magento Commerce 1.14.3.6和开源1.9.3.6包含多项安全增强功能,可帮助关闭跨站点请求伪造(CSRF),未经授权的数据泄漏以及经过身份验证的Admin用户远程执行代码漏洞。这些版本还包括针对图像重新加载和使用单步付款的付款问题的修复程序。
Magento 1的新安全补丁已发布,解决了13个APPSEC问题
https://magento.com/security/patches/supee-10266
应用此修补程序时,您需要注意哪些常见问题?
SUPEE-10266,Magento Commerce 1.14.3.6和开源1.9.3.6包含多项安全增强功能,可帮助关闭跨站点请求伪造(CSRF),未经授权的数据泄漏以及经过身份验证的Admin用户远程执行代码漏洞。这些版本还包括针对图像重新加载和使用单步付款的付款问题的修复程序。
Answers:
一些重要的信息在这里共享。大部分来自Magento后端的文件。该文件列出:
app/code/core/Mage/Admin/Model/Session.php
app/code/core/Mage/Adminhtml/Block/Notification/Grid/Renderer/Notice.php
app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php
app/code/core/Mage/Adminhtml/Controller/Action.php
app/code/core/Mage/Adminhtml/Model/LayoutUpdate/Validator.php
app/code/core/Mage/Adminhtml/controllers/CustomerController.php
app/code/core/Mage/Adminhtml/controllers/Newsletter/TemplateController.php
app/code/core/Mage/Checkout/controllers/CartController.php
app/code/core/Mage/Core/Model/Email/Template/Abstract.php
app/code/core/Mage/Core/Model/File/Validator/Image.php
app/code/core/Mage/Core/Model/Session/Abstract/Varien.php
app/code/core/Mage/Core/etc/config.xml
app/code/core/Mage/Rss/Helper/Data.php
app/code/core/Mage/Sales/Model/Resource/Order/Item/Collection.php
app/code/core/Zend/Serializer/Adapter/PhpCode.php
app/design/adminhtml/default/default/template/backup/dialogs.phtml
app/design/adminhtml/default/default/template/catalog/product/edit/options/type/file.phtml
app/design/adminhtml/default/default/template/customer/tab/view.phtml
app/design/adminhtml/default/default/template/login.phtml
app/design/adminhtml/default/default/template/notification/toolbar.phtml
app/design/adminhtml/default/default/template/oauth/authorize/form/login.phtml
app/design/adminhtml/default/default/template/resetforgottenpassword.phtml
app/design/adminhtml/default/default/template/sales/order/view/history.phtml
app/design/adminhtml/default/default/template/sales/order/view/info.phtml
app/design/install/default/default/template/install/create_admin.phtml
app/locale/en_US/Mage_Adminhtml.csv
downloader/template/login.phtml
重要的是需要检查这三个文件。
app/code/core/Mage/Checkout/controllers/CartController.php
app/code/core/Mage/Sales/Model/Resource/Order/Item/Collection.php
app/code/core/Mage/Core/Model/File/Validator/Image.php
app / code / core / Mage / Checkout / controllers / CartController.php其他条件检查客户ID:
diff --git app/code/core/Mage/Checkout/controllers/CartController.php app/code/core/Mage/Checkout/controllers/CartController.php
index 7c9f28f..bee6034 100644
--- app/code/core/Mage/Checkout/controllers/CartController.php
+++ app/code/core/Mage/Checkout/controllers/CartController.php
@@ -284,14 +284,16 @@ class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action
public function addgroupAction()
{
$orderItemIds = $this->getRequest()->getParam('order_items', array());
+ $customerId = $this->_getCustomerSession()->getCustomerId();
- if (!is_array($orderItemIds) || !$this->_validateFormKey()) {
+ if (!is_array($orderItemIds) || !$this->_validateFormKey() || !$customerId) {
$this->_goBack();
return;
}
$itemsCollection = Mage::getModel('sales/order_item')
->getCollection()
+ ->addFilterByCustomerId($customerId)
->addIdFilter($orderItemIds)
->load();
/* @var $itemsCollection Mage_Sales_Model_Mysql4_Order_Item_Collection */
@@ -709,4 +711,14 @@ class Mage_Checkout_CartController extends Mage_Core_Controller_Front_Action
$this->getResponse()->setHeader('Content-type', 'application/json');
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
+
+ /**
+ * Get customer session model
+ *
+ * @return Mage_Customer_Model_Session
+ */
+ protected function _getCustomerSession()
+ {
+ return Mage::getSingleton('customer/session');
+ }
}
添加了app / code / core / Mage / Sales / Model / Resource / Order / Item / Collection.php集合中的附加方法addFilterByCustomerId。
diff --git app/code/core/Mage/Sales/Model/Resource/Order/Item/Collection.php app/code/core/Mage/Sales/Model/Resource/Order/Item/Collection.php
index ee83ad48..c02afdf 100644
--- app/code/core/Mage/Sales/Model/Resource/Order/Item/Collection.php
+++ app/code/core/Mage/Sales/Model/Resource/Order/Item/Collection.php
@@ -152,4 +152,20 @@ class Mage_Sales_Model_Resource_Order_Item_Collection extends Mage_Sales_Model_R
$this->getSelect()->where($resultCondition);
return $this;
}
+
+ /**
+ * Filter by customerId
+ *
+ * @param int|array $customerId
+ * @return Mage_Sales_Model_Resource_Order_Item_Collection
+ */
+ public function addFilterByCustomerId($customerId)
+ {
+ $this->getSelect()->joinInner(
+ array('order' => $this->getTable('sales/order')),
+ 'main_table.order_id = order.entity_id', array())
+ ->where('order.customer_id IN(?)', $customerId);
+
+ return $this;
+ }
}
应用程序/代码/核心/法师/核心/模型/文件/验证器/Image.php
如果'general / reprocess_images / active'为false,则跳过图像重新处理。注意:如果您关闭图像再处理,则您的上传图像过程可能会导致安全风险
diff --git app/code/core/Mage/Core/Model/File/Validator/Image.php app/code/core/Mage/Core/Model/File/Validator/Image.php
index 9d57202..6a939c3 100644
--- app/code/core/Mage/Core/Model/File/Validator/Image.php
+++ app/code/core/Mage/Core/Model/File/Validator/Image.php
@@ -91,6 +91,13 @@ class Mage_Core_Model_File_Validator_Image
list($imageWidth, $imageHeight, $fileType) = getimagesize($filePath);
if ($fileType) {
if ($this->isImageType($fileType)) {
+ /**
+ * if 'general/reprocess_images/active' false then skip image reprocessing.
+ * NOTE: If you turn off images reprocessing, then your upload images process may cause security risks.
+ */
+ if (!Mage::getStoreConfigFlag('general/reprocess_images/active')) {
+ return null;
+ }
//replace tmp image with re-sampled copy to exclude images with malicious data
$image = imagecreatefromstring(file_get_contents($filePath));
if ($image !== false) {
希望对您有所帮助。我认为
EE 1.14.2.4
错字在贴片的726行:autocomplete="new-pawwsord"
(app/design/adminhtml/default/default/template/backup/dialogs.phtml)
该补丁似乎缺少2个前端文件:
已修补:
app\design\adminhtml\default\default\template\oauth\authorize\form\login-simple.phtml
未修补:
app\design\frontend\base\default\template\oauth\authorize\form\login-simple.phtml
app\design\frontend\rwd\default\template\oauth\authorize\form\login-simple.phtml
另外不要忘了检查本地替代...我不得不手动修补本地代码池的替代 app\design\adminhtml\default\default\template\sales\order\view\info.phtml
有关一页结帐问题,请参阅quasiobject的答案。已创建企业支持票证,正在等待Magento的答复。如果您不想等待更新的补丁,则潜在的解决方法是修改“ else”语句,app\design\frontend\enterprise\default\template\giftcardaccount\onepage\payment\scripts.phtml使其包含form_key元素,如下所示:
if (($('p_method_' + methodName) && $('p_method_' + methodName).checked) || elements[i].name == 'form_key') { ...
CE 1.9.2.4
错字在贴片694行:autocomplete="new-pawwsord"
(app/design/adminhtml/default/default/template/backup/dialogs.phtml)
需要修补TrueOrderEdit扩展... 在以下文件中更改echo $_groupName为echo $this->escapeHtml($_groupName):
app\design\adminhtml\default\default\template\orderedit\sales\order\view\edit.phtml
app\design\adminhtml\default\default\template\orderedit\sales\order\view\history.phtml
app\design\adminhtml\default\default\template\orderedit\sales\order\view\info.phtml
最后,此核心模板文件可能还应该使用相同的$ _groupName更新进行修补:
app\design\adminhtml\default\default\template\sales\order\view\edit.phtml
所有1.X版本
如果您已从代码库中删除了/downloader文件夹(或/downloader/template),则可能必须手动编辑.sh补丁文件并删除最后一部分,从diff --git downloader/template/login.phtml downloader/template/login.phtml
关于无效密钥错误,请在此处查看我的答案:Magento 1.9无效密钥。请刷新页面
我们在MageHost.pro找到了Magento 1.9.1.1补丁文件中的问题PATCH_SUPEE-10266_CE_1.9.1.1_v1-2017-09-15-04-59-56.sh
错误:
checking file app/code/core/Mage/Core/Model/File/Validator/Image.php
Hunk #1 FAILED at 90.
1 out of 1 hunk FAILED
我通过用454-471将454-472行替换为 PATCH_SUPEE-10266_CE_1.9.1.0_v1-2017-09-13-06-34-33.sh
旧代码,行454-472:
diff --git app/code/core/Mage/Core/Model/File/Validator/Image.php app/code/core/Mage/Core/Model/File/Validator/Image.php
index 7f7b9d0..8a28da2 100644
--- app/code/core/Mage/Core/Model/File/Validator/Image.php
+++ app/code/core/Mage/Core/Model/File/Validator/Image.php
@@ -90,7 +90,13 @@ class Mage_Core_Model_File_Validator_Image
$fileInfo = getimagesize($filePath);
if (is_array($fileInfo) and isset($fileInfo[2])) {
if ($this->isImageType($fileInfo[2])) {
- return null;
+ /**
+ * if 'general/reprocess_images/active' false then skip image reprocessing.
+ * NOTE: If you turn off images reprocessing, then your upload images process may cause security risks.
+ */
+ if (!Mage::getStoreConfigFlag('general/reprocess_images/active')) {
+ return null;
+ }
}
}
throw Mage::exception('Mage_Core', Mage::helper('core')->__('Invalid MIME type.'));
新代码,第454-471行:
diff --git app/code/core/Mage/Core/Model/File/Validator/Image.php app/code/core/Mage/Core/Model/File/Validator/Image.php
index 8618bca..d3aba19 100644
--- app/code/core/Mage/Core/Model/File/Validator/Image.php
+++ app/code/core/Mage/Core/Model/File/Validator/Image.php
@@ -90,6 +90,13 @@ class Mage_Core_Model_File_Validator_Image
list($imageWidth, $imageHeight, $fileType) = getimagesize($filePath);
if ($fileType) {
if ($this->isImageType($fileType)) {
+ /**
+ * if 'general/reprocess_images/active' false then skip image reprocessing.
+ * NOTE: If you turn off images reprocessing, then your upload images process may cause security risks.
+ */
+ if (!Mage::getStoreConfigFlag('general/reprocess_images/active')) {
+ return null;
+ }
//replace tmp image with re-sampled copy to exclude images with malicious data
$image = imagecreatefromstring(file_get_contents($filePath));
if ($image !== false) {
在此补丁中似乎只添加了一个Form键。
diff --git app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php
index 8756f3f..1c5cf37 100644
--- app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php
+++ app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php
@@ -96,7 +96,10 @@ class Mage_Adminhtml_Block_Widget_Form_Container extends Mage_Adminhtml_Block_Wi
public function getDeleteUrl()
{
- return $this->getUrl('*/*/delete', array($this->_objectId => $this->getRequest()->getParam($this->_objectId)));
+ return $this->getUrl('*/*/delete', array(
+ $this->_objectId => $this->getRequest()->getParam($this->_objectId),
+ Mage_Core_Model_Url::FORM_KEY => $this->getFormKey()
+ ));
}
因此,如果您在从管理面板中删除窗口小部件时遇到任何困难,请确保您的删除网址是由该代码块生成的,并且您没有对该代码块的替代。
在app/design/frontend/enterprise/default/template/giftcardaccount/onepage/payment/scripts.phtml表单中,密钥验证代码已被删除,它破坏了整个结帐,更多信息请参见:https : //magento.stackexchange.com/a/193442/2380
目前的解决方法(因为EE 1.11+的V2版本将发布,以解决该问题):回滚两个模板enterprise/default和rwd/entreprise主题模板文件。
编辑:1.9.3.6已发布,因此此信息不再相关
目前提出的主要问题之一是1.9.3.5缺少3个安全补丁。因此,我强烈建议您仅打补丁而不升级到1.9.3.5。
由于自定义模板,仍在尝试确定这是否对我们的商店而言唯一。但是,它在应用补丁程序时被破坏,而在还原时并没有被破坏。我想发表,以防其他人举报。
在EE 1.14.2.0中,应用补丁程序后,我们无法继续进行“付款信息”步骤的结帐。在应用新补丁之前,我们当前最新版本为SUPEE-9767 v2。
我们的问题似乎源于将它们|| elements[i].name == 'form_key'从以下位置删除:
app/design/frontend/enterprise/default/template/giftcardaccount/onepage/payment/scripts.phtml
它已从enablePaymentMethods循环中删除。这似乎使表单的隐藏的form_key输入保持禁用状态,因此在提交时不会传递给控制器。
<input name="form_key" type="hidden" value="X" disabled="">
然后,$this->_validateFormKey()失败并且控制器什么也不返回。
更新1(2017-09-18):我在周五向Magento支持人员提交了一张票,并被告知“尚未有任何商人举报”。我没有发送备份,而是尝试使用适用的修补程序在1.14.2.4和1.14.3.4的全新安装中进行复制。我能够复制票并对其进行了回复。等待新的回应。
注意:“系统”>“配置”>“管理”>“安全性”>“在结帐时启用表单密钥验证”需要为“是”。如果为“否”,则不会看到该问题。
更新2(2017年9月18日):发现我能不能跟1.14.3.6复制的问题,但是当我检查模板文件上面,|| elements[i].name == 'form_key'仍然存在。似乎补丁不应该删除它。也将此信息也发送给了Magento支持。
更新3(2017-09-20):我刚刚得到一个补丁来解决1.14.0.0–1.14.3.4的问题,该问题只是将form_key行恢复到模板中。寻求SUPEE-10348的支持。
当您转到Magento Connect时,以及在单击页面右上角的“返回到管理员”之后。返回管理控制台后,您会收到一条错误消息
红色 错误消息: “无效密钥。请刷新页面。”
刷新页面后,页面消失了。
更新时间:2017年9月15日
如果您登录Magento管理员,请说“仪表板”。无需从“仪表板”面板注销,您可以在同一浏览器中打开另一个浏览器窗口,然后转到example.com/admin,它将自动登录并显示完全相同的消息。
红色 错误消息: “无效密钥。请刷新页面。”
到目前为止,这是我发现的唯一问题。我什至不确定它是否是一个可靠的问题,因为刷新后消息消失了。
if ($_keyErrorMsg != '') { Mage::getSingleton('adminhtml/session')->addError($_keyErrorMsg); };应该是if (!$_isValidFormKey){ Mage::getSingleton('adminhtml/session')->addError($_keyErrorMsg); };
我询问了Magento支持人员有关以下问题的信息
app/design/frontend/enterprise/default/template/giftcardaccount/onepage/payment/scripts.phtml
他们今天早上回答了我,并发布了新补丁PATCH_SUPEE-10348。
Magento只是通过还原此文件来解决该问题。
索引:app / design / frontend / enterprise / default / template / giftcardaccount / onepage / payment / scripts.phtml
================================================== =================
--- app / design / frontend / enterprise / default / template / giftcardaccount / onepage / payment / scripts.phtml
+++ app / design / frontend / enterprise / default / template / giftcardaccount / onepage / payment / scripts.phtml
@@ -35,6 +35,7 @@
如果(elements [i] .name =='payment [method]'
|| elements [i] .name =='payment [use_customer_balance]'
|| elements [i] .name =='payment [use_reward_points]'
+ || elements [i] .name =='form_key'
){
methodName = elements [i] .value;
如果((free && methodName =='free')||(!free && methodName!='free')){
我在使用电子邮件模板,自定义CSS和modman时遇到了问题。如果您有一个基于的主题rwd/default,有一个自定义,skin/frontend/package/theme/css/email-inline.css并且您的皮肤文件是通过符号链接通过modman包含的,则在应用SUPEE-10266之后,CSS将不会添加到邮件模板中。问题是,在中Mage_Core_Model_Email_Template_Abstract::_getCssFileContent引入了一些检查。:
'_theme' => $theme,
)
);
+ $filePath = realpath($filePath);
+ $positionSkinDirectory = strpos($filePath, Mage::getBaseDir('skin'));
+ $validator = new Zend_Validate_File_Extension('css');
- if (is_readable($filePath)) {
+ if ($validator->isValid($filePath) && $positionSkinDirectory !== false && is_readable($filePath)) {
return (string) file_get_contents($filePath);
}
我app/code/local/Mage/Core/Model/Email/Template/Abstract.php暂时用一个肮脏的hack解决了它。我不得不弱化检查,以便可以从modman目录加载CSS文件:
$filePath = realpath($filePath);
$baseDirectory = Mage::getBaseDir();
$fullSkinDirectory = Mage::getBaseDir('skin');
$relativeSkinDirectory = substr($fullSkinDirectory, strlen($baseDirectory));
$positionSkinDirectory = strpos($filePath, $relativeSkinDirectory);
$validator = new Zend_Validate_File_Extension('css');
$noDirectoryTraversal = strpos($filename, '..') === false;
if ($validator->isValid($filePath) && $positionSkinDirectory !== false && $noDirectoryTraversal
&& is_readable($filePath)) {
return (string) file_get_contents($filePath);
}
它不会再检查路径是否包含完整的外观目录,而只会检查路径是否包含字符串/skin以及是否不包含..,这应该可以防止目录遍历攻击。
if (strpos($filename, '..') === false) { $positionSkinDirectory = 1; }在$positionSkinDirectory最初设置后检查该行。这应该有助于避免目录遍历。
这是受autocomplete="new-pawwsord"拼写错误影响的补丁程序的完整列表:
CE 1.7.0.0-1.7.0.2 PATCH_SUPEE-10266_CE_1.7.0.2_v1-2017-09-13-06-27-12.sh:664
CE 1.8.0.0-1.8.1.0 PATCH_SUPEE-10266_CE_1.8.1.0_v1-2017-09-13-06-28-08.sh:665
CE 1.9.0.0-1.9.0.1 PATCH_SUPEE-10266_CE_1.9.0.1_v1-2017-09-13-06-31-01.sh:665
CE 1.9.1.0 PATCH_SUPEE-10266_CE_1.9.1.0_v1-2017-09-13-06-34-33.sh:733
CE 1.9.1.1 PATCH_SUPEE-10266_CE_1.9.1.1_v1-2017-09-15-04-59-56.sh:734
CE 1.9.2.0-1.9.2.4 PATCH_SUPEE-10266_CE_1.9.2.4_v1-2017-09-13-06-37-37.sh:694
CE 1.9.3.0-1.9.3.2 PATCH_SUPEE-10266_CE_1.9.3.2_v1-2017-09-13-06-38-58.sh:694
CE 1.9.3.3-1.9.3.4 PATCH_SUPEE-10266_CE_1.9.3.4_v1-2017-09-13-06-39-58.sh:694
EE 1.12.0.0 PATCH_SUPEE-10266_EE_1.12.0.0_v1-2017-09-13-08-09-14.sh:696
EE 1.12.0.1-1.12.0.2 PATCH_SUPEE-10266_EE_1.12.0.2_v1-2017-09-13-08-06-57.sh:696
EE 1.13.0.0-1.13.1.0 PATCH_SUPEE-10266_EE_1.13.1.0_v1-2017-09-13-08-04-05.sh:696
EE 1.14.0.0-1.14.0.1 PATCH_SUPEE-10266_EE_1.14.0.1_v1-2017-09-13-08-01-04.sh:696
EE 1.14.1.0 PATCH_SUPEE-10266_EE_1.14.1.0_v1-2017-09-13-07-57-59.sh:764
EE 1.14.2.0 PATCH_SUPEE-10266_EE_1.14.2.0_v1-2017-09-13-07-07-14.sh:764
EE 1.14.2.1-1.14.2.4 PATCH_SUPEE-10266_EE_1.14.2.4_v1-2017-09-13-06-57-21.sh:726
EE 1.14.3.0-1.14.3.2 PATCH_SUPEE-10266_EE_1.14.3.2_v1-2017-09-13-06-53-35.sh:716
EE 1.14.3.3-1.14.3.4 PATCH_SUPEE-10266_EE_1.14.3.3_v1-2017-09-13-06-51-06.sh:716
在Magento 1.8.1上,我遇到了以下文件的问题:
app/code/core/Mage/Core/Model/File/Validator/Image.php
app/code/core/Mage/Core/etc/config.xml
app/locale/en_US/Mage_Adminhtml.csv
我最终下载了不包含该补丁的最新Magento版本。在这种情况下,Magento 1.9.3.4。
用下载中的文件替换“损坏的”文件可解决此问题。我能够成功应用补丁。
但请注意:建议再次修补后还原3个文件,然后手动编辑文件。