HXSecurity / DongTai

Dongtai IAST is an open-source Interactive Application Security Testing (IAST) tool that enables real-time detection of common vulnerabilities in Java applications and third-party components through passive instrumentation. It is particularly suitable for use in the testing phase of the development pipeline.
https://dongtai.io
Apache License 2.0
1.24k stars 145 forks source link

[BUG] XXEChecker对Unmarshaller无效 #1912

Closed RTxin closed 11 months ago

RTxin commented 11 months ago

Preflight Checklist

Version

1.14.0

Installation Type

Other (specify below)

Service Name

DongTai-agent-java

Describe the details of the bug and the steps to reproduce it

这是我使用的Unmarshalleer接口demo方法,设置 xif.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");后是有被阻断的,但似乎在XXEChecker没有获取到所需配置导致误报

            JAXBContext context = JAXBContext.newInstance(Student.class);
            Unmarshaller unmarshaller = context.createUnmarshaller();

            XMLInputFactory xif = XMLInputFactory.newFactory();
            // fixed: 禁用外部实体
             xif.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
//             xif.setProperty(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");

            // 默认情况下在1.8版本上不能加载外部dtd文件,需要更改设置。
             xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
             xif.setProperty(XMLInputFactory.SUPPORT_DTD, false);
            XMLStreamReader xsr = xif.createXMLStreamReader(new StringReader(content));
            Object o = unmarshaller.unmarshal(xsr);

Additional Information

且在JDK9模块化后,在不使用--illegal-access的情况下会出现部分反射没法用,此时XXEChecker也处于无效状态 module java.xml does not "opens com.sun.org.apache.xerces.internal.parsers" to unnamed module

Logs

No response