希望将 disallow-doctype-decl 功能设置为 true 以阻止 XXE 攻击

问题描述 投票:0回答:2

我们使用 spring ws 作为过滤器,根据传入的肥皂请求上的令牌、时间戳和签名执行 WS-Security。

我们希望使用相同的过滤器来防止 XXE 攻击,并想知道它是否可能。

我们使用“org.springframework.ws.soap.axiom.AxiomSoapMessageFactory”作为消息工厂,它有两个设置器“setSupportingExternalEntities”和“setReplacingEntityReferences”,默认情况下为 false。

]>

现在,如果在soap请求中使用doctype声明一个实体,并使用&xxe;引用它。然后 spring 框架返回一个错误

org.apache.axiom.soap.SOAPProcessingException: A SOAP message cannot contain entity references because it must not have a DTD
2018-05-18T13:14:33,272 DEBUG [org.springframework.ws.soap.server.SoapMessageDispatcher] Endpoint invocation resulted in exception - responding with Fault
org.apache.axiom.soap.SOAPProcessingException: A SOAP message cannot contain entity references because it must not have a DTD
    at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.createEntityReference(StAXSOAPModelBuilder.java:359) ~[axiom-api-1.2.15.jar:1.2.15]
    at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:279) ~[axiom-api-1.2.15.jar:1.2.15]

但是如果我们替换 &name; 就不会出现这个错误。与 &xxe;或&xxe; Spring ws框架让它通过。

我不希望它进行任何进一步的处理,所以如果可能的话,我们可以以某种方式不允许在肥皂请求中声明文档类型本身。

感谢您提供解决此问题的任何帮助和指示

spring-mvc spring-ws axiom
2个回答
1
投票

添加我如何解决这个问题。没有找到在 spring-ws 过滤器中处理它的方法,并且 Spring 没有行为不当,因为它没有尝试解析传递的实体。

在项目流程的后面,我们使用标准 java DOM 解析器库并添加

factory.setFeature(DISALLOW_DOCTYPE_DECL_FEATURE, true);

我们能够停止解决 XXE 问题的 DTD 声明。


0
投票

我想解决这个问题,您能否添加一些如何解决此问题的代码片段。

© www.soinside.com 2019 - 2024. All rights reserved.