本地测试方式
给回调地址发送以下数据
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE Anything [
<!ENTITY entityex SYSTEM "本地另一个域名">
]>
<abc>&entityex;</abc>
生效则后台爆出异常(此处为java的处理结果)
Error on line 3 of document : 将功能 “http://apache.org/xml/features/disallow-doctype-decl” 设置为“真”时, 不允许使用 DOCTYPE。 Nested exception: 将功能 “http://apache.org/xml/features/disallow-doctype-decl” 设置为“真”时, 不允许使用 DOCTYPE。
未生效有注入的情况
会访问“本地另一个域名”
微信的解决方案
https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=23_5
参考资料
XML文件的解析以及XML外部实体注入防护
https://blog.csdn.net/u013224189/article/details/49759845
java 生成xml
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.newDocument()
document.setXmlStandalone(true);
org.w3c.dom.Element xml = document.createElement("xml");
document.appendChild(xml);
org.w3c.dom.Element return_codexml = document.createElement("return_code");
return_codexml.appendChild(document.createCDATASection("SUCCESS"));
xml.appendChild(return_codexml);
org.w3c.dom.Element return_msgxml = document.createElement("return_msg");
return_msgxml.appendChild(document.createCDATASection("OK"));
xml.appendChild(return_msgxml);
org.w3c.dom document 和xml 字符串 互转
https://blog.csdn.net/wmyasw/article/details/8686420
<!CDATA[]]用法详解
https://www.cnblogs.com/bdqczhl/p/7217243.html