XXE漏洞防禦和驗證方法

驗證是否存在漏洞方法

使用如下請求調試你的微信支付結果通知接口java

1.將 https://path/to/your/wxApp/notify 替換爲你的微信支付通知接口便可git

curl -X POST -H "Content-Type: application/xml" -H "Cache-Control: no-cache" -d '<?xml version="1.0"?>
<!DOCTYPE ANY [<!ENTITY send SYSTEM "http://www.baidu.com">]>
<x>send;</x>' "https://path/to/your/wxApp/notify"

2.若是後臺輸出如下錯誤,說明不存在XXE漏洞github

org.xml.sax.SAXParseExcepxception; lineNumber: 2; columnNumber: 10; DOCTYPE is disallowed when the feature "e "http://apache.org/xml/features/disallow-doctype-decl" se" set to true.

請注意

因爲目前我這裏使用的都是SAXReader解析XML,因此個別報錯信息會和個人有差異,供參考。shell

防禦措施

能夠使用微信官方SDK包中的com.github.wxpay.sdk.WXPayXmlUtil類來生成可預防XXE漏洞的documentBuilderFactoryapache

參考文檔: https://blog.csdn.net/u013224189/article/details/49759845微信

相關文章
相關標籤/搜索