1. XXE漏洞消亡原因
libxml2.9.0以后,默认不解析外部实体,导致XXE漏洞逐渐消亡。http://www.linuxfromscratch.org/blfs/view/cvs/general/libxml2.html
2. XXE漏洞防御
1、使用开发语言提供的禁用外部实体的方法
PHP:
libxml_disable_entity_loader(true);
JAVA:
DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();
dbf.setExpandEntityReferences(false);
Python:
from lxml import etree
xmlData = etree.parse(xmlSource,etree.XMLParser(resolve_entities=False))
2、过滤用户提交的XML数据
关键词:<!DOCTYPE和<!ENTITY,或者,SYSTEM和PUBLIC。