Skip to content

Commit 71c58bf

Browse files
author
liyi
committed
#158 #159 XML 解析 XXE漏洞处理
1 parent 3a62a16 commit 71c58bf

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

changelog.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ WEIXIN-POPULAR CHANGELOG
22
===========================
33
https://github.com/liyiorg/weixin-popular
44

5-
Changes in version 2.8.21 (2018-07-?)
5+
Changes in version 2.8.21 (2018-07-06)
66
-------------------------------------
77
* 退款申请接口添加 refund_desc 退款原因字段
88
* 升级依赖emoji-java 版本到 4.0.0
99
* 升级依赖fastjson 版本到 1.2.47
1010
* #156 JsUtil.generateConfigJson 规范JSON数据格式
1111
* #157 统一下单添加H5 场景支持
12+
* #158 #159 XML 解析 XXE漏洞处理
13+
1214

1315
Changes in version 2.8.20 (2018-05-28)
1416
-------------------------------------

src/main/java/com/qq/weixin/mp/aes/XMLParse.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ public static Object[] extract(String xmltext) throws AesException {
3535
Object[] result = new Object[3];
3636
try {
3737
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
38+
39+
/*
40+
* 避免 XXE 攻击
41+
* @since 2.8.21
42+
*/
43+
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
44+
dbf.setXIncludeAware(false);
45+
dbf.setExpandEntityReferences(false);
46+
3847
DocumentBuilder db = dbf.newDocumentBuilder();
3948
StringReader sr = new StringReader(xmltext);
4049
InputSource is = new InputSource(sr);

src/main/java/weixin/popular/util/XMLConverUtil.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,15 @@ public static Map<String,String> convertToMap(String xml){
140140
Map<String, String> map = new LinkedHashMap<String,String>();
141141
try {
142142
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
143+
144+
/*
145+
* 避免 XXE 攻击
146+
* @since 2.8.21
147+
*/
148+
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
149+
dbf.setXIncludeAware(false);
150+
dbf.setExpandEntityReferences(false);
151+
143152
DocumentBuilder db = dbf.newDocumentBuilder();
144153
StringReader sr = new StringReader(xml);
145154
InputSource is = new InputSource(sr);
@@ -162,4 +171,5 @@ public static Map<String,String> convertToMap(String xml){
162171
}
163172
return map;
164173
}
174+
165175
}

0 commit comments

Comments
 (0)