聯(lián)系官方銷售客服
1835022288
028-61286886
微信支付商戶,最近暴露的XML外部實(shí)體注入漏洞(XML External Entity Injection,簡稱 XXE),該安全問題是由XML組件默認(rèn)沒有禁用外部實(shí)體引用導(dǎo)致,非微信支付系統(tǒng)存在漏洞。
如果你在使用支付業(yè)務(wù)回調(diào)通知中,存在以下場景有使用XML解析的情況,請務(wù)必檢查是否對進(jìn)行了防范。
場景1:支付成功通知;
場景2:退款成功通知;
場景3:委托代扣簽約、解約、扣款通知;
場景4:車主解約通知;
場景5:掃碼支付模式一回調(diào);
注:APP支付的用戶端SDK不受影響,但APP支付成功回調(diào)通知里面要檢查。
微信支付會(huì)通過這幾個(gè)系統(tǒng)號碼通知商戶進(jìn)行安全周知和詢問是否授權(quán)平臺進(jìn)行安全掃描。
(0755)36560292
(0755)61954612
(0755)61954613
(0755)61954614
(0755)61954615
(0755)61954616
授權(quán)檢測支付系統(tǒng)操作,不會(huì)影響商戶系統(tǒng)安全。
注:商戶如需自我檢測XXE漏洞,可前往商戶平臺(pay.weixin.qq.com)-->產(chǎn)品中心-->安全醫(yī)生進(jìn)行測試。
1.如果您的后臺系統(tǒng)使用了官方SDK,請更新SDK到最新版本 SDK的鏈接:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=11_1
2.如果您是有系統(tǒng)提供商,請聯(lián)系提供商進(jìn)行核查和升級修復(fù);
3.如果您是自研系統(tǒng),請聯(lián)系技術(shù)部門按以下指引核查和修復(fù):
如有疑問,可通過郵箱WePayTS@tencent.com與我們聯(lián)系,感謝您對微信支付的支持。
XXE漏洞需要你在代碼中進(jìn)行相應(yīng)的設(shè)置,不同語言設(shè)置的內(nèi)容不同,下面提供了幾種主流開發(fā)語言的設(shè)置指引:
【PHP】
libxml_disable_entity_loader(true);
【JAVA】
import javax.xml.parsers.DocumentBuilderFactory;import javax.xml.parsers.ParserConfigurationException; // catching unsupported featuresDocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();String FEATURE = null;try { // This is the PRIMARY defense. If DTDs (doctypes) are disallowed, almost all XML entity attacks are prevented // Xerces 2 only - http://xerces.apache.org/xerces2-j/features.html#disallow-doctype-decl FEATURE = "http://apache.org/xml/features/disallow-doctype-decl"; dbf.setFeature(FEATURE, true); // If you can't completely disable DTDs, then at least do the following: // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-general-entities // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-general-entities // JDK7+ - http://xml.org/sax/features/external-general-entities FEATURE = "http://xml.org/sax/features/external-general-entities"; dbf.setFeature(FEATURE, false); // Xerces 1 - http://xerces.apache.org/xerces-j/features.html#external-parameter-entities // Xerces 2 - http://xerces.apache.org/xerces2-j/features.html#external-parameter-entities // JDK7+ - http://xml.org/sax/features/external-parameter-entities FEATURE = "http://xml.org/sax/features/external-parameter-entities"; dbf.setFeature(FEATURE, false); // Disable external DTDs as well FEATURE = "http://apache.org/xml/features/nonvalidating/load-external-dtd"; dbf.setFeature(FEATURE, false); // and these as well, per Timothy Morgan's 2014 paper: "XML Schema, DTD, and Entity Attacks" dbf.setXIncludeAware(false); dbf.setExpandEntityReferences(false); // And, per Timothy Morgan: "If for some reason support for inline DOCTYPEs are a requirement, then // ensure the entity settings are disabled (as shown above) and beware that SSRF attacks // (http://cwe.mitre.org/data/definitions/918.html) and denial // of service attacks (such as billion laughs or decompression bombs via "jar:") are a risk." // remaining parser logic} catch (ParserConfigurationException e) { // This should catch a failed setFeature feature logger.info("ParserConfigurationException was thrown. The feature '" + FEATURE + "' is probably not supported by your XML processor."); }catch (SAXException e) { // On Apache, this should be thrown when disallowing DOCTYPE logger.warning("A DOCTYPE was passed into the XML document"); }catch (IOException e) { // XXE that points to a file that doesn't exist logger.error("IOException occurred, XXE may still possible: " + e.getMessage()); } DocumentBuilder safebuilder = dbf.newDocumentBuilder();
【.Net】
XmlDocument doc= new XmlDocument(); doc.XmlResolver = null;
【ASP】
Set xmldom = Server.CreateObject("MSXML2.DOMDocument") xmldom.resolveExternals = false
【Python】
from lxml import etree xmlData = etree.parse(xmlSource,etree.XMLParser(resolve_entities=False))
【c/c++(常用庫為libxml2 libxerces-c)】 【libxml2】: 確保關(guān)閉配置選項(xiàng):XML_PARSE_NOENT 和 XML_PARSE_DTDLOAD
2.9版本以上已修復(fù)XXE
【libxerces-c】:
如果用的是XercesDOMParser:
XercesDOMParser *parser = new XercesDOMParser; parser->setCreateEntityReferenceNodes(false);
如果是用SAXParser:
SAXParser* parser = new SAXParser; parser->setDisableDefaultEntityResolution(true);
如果是用SAX2XMLReader:
SAX2XMLReader* reader = XMLReaderFactory::createXMLReader(); parser->setFeature(XMLUni::fgXercesDisableDefaultEntityResolution, true);
附錄:更多開源庫/語言版本的修復(fù)建議可參考:
https://www.owasp.org/index.php/XML_External_Entity_(XXE)_Prevention_Cheat_Sheet#C.2FC.2B.2B
看不懂
請問你的修復(fù)了嗎
沒有,要改pHp,不知改poscms的什么地方
在微信支付xxe漏洞維修團(tuán)隊(duì)的幫助下終于修復(fù),請官方也修復(fù)吧,免得大家沒頭緒,修改\api\pay\weixin\WxPayPubHelper\WxPayPubHelper.php中
....
//將xml轉(zhuǎn)為array
libxml_disable_entity_loader(true); //關(guān)鍵代碼,修復(fù)XXE
在 $array_data = .... 前添加上面一段代碼
微信安全團(tuán)隊(duì)檢查通過,恢復(fù)被凍結(jié)賬號