0

我正在尝试通过使用 struts 1.3.8 的应用程序来实现 HDIV。我在 pom 文件和监听器中添加了依赖项,在 web.xml 文件中进行了过滤。

令牌_HDIV_STATE_被注入每个页面,链接..所以为了测试它是否按预期工作以对抗CSRF攻击,我在应用程序外部制作了一个小html页面,将数据发送到应用程序以修改一些数据以模拟CSRF攻击。

不幸的是,测试成功了,因为目标数据被修改了。当我检查日志时,似乎 HDIV 检测到该请求不包含 _HDIV_STATE_ 但它没有取消它并重定向到错误页面或其他内容。

我的配置是错的,还是我不明白请求中不存在令牌时 HDIV 会做什么?

谢谢你的帮助

pom.xml:

<dependency>
            <groupId>org.hdiv</groupId>
            <artifactId>hdiv-config</artifactId>
            <version>2.1.12</version>
</dependency>
<dependency>
            <groupId>org.hdiv</groupId>
            <artifactId>hdiv-struts-1</artifactId>
            <version>2.1.12</version>
</dependency>
<dependency>
            <groupId>org.hdiv</groupId>
            <artifactId>hdiv-jstl-taglibs-1.2</artifactId>
            <version>2.1.12</version>
</dependency>

web.xml

<listener>
    <listener-class>org.hdiv.listener.InitListener</listener-class>
</listener>
<filter>
    <filter-name>ValidatorFilter</filter-name>
    <filter-class>org.hdiv.filter.ValidatorFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>ValidatorFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<jsp-config>
<taglib>
    <taglib-uri>/WEB-INF/tld/struts-html-el.tld</taglib-uri>
    <taglib-location>/WEB-INF/tld/hdiv-html-el.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>/WEB-INF/tld/struts-logic-el.tld</taglib-uri>
    <taglib-location>/WEB-INF/tld/hdiv-logic-el.tld</taglib-location>
</taglib>

<taglib>
    <taglib-uri>/WEB-INF/tld/c.tld</taglib-uri>
    <taglib-location>/WEB-INF/tld/hdiv-c.tld</taglib-location>
</taglib>
</jsp-config>

hdiv-config.hml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
       xmlns:hdiv="http://www.hdiv.org/schema/hdiv" 
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
                           http://www.hdiv.org/schema/hdiv 
                           http://www.hdiv.org/schema/hdiv/hdiv.xsd">

    <hdiv:config excludedExtensions="css,png,gif,jpeg,jpg,js" errorPage="/error.jsp" 
                 maxPagesPerSession="2" debugMode="true">
        <hdiv:sessionExpired loginPage="/index.jsp" homePage="/"/>
        <hdiv:startPages>/index.jsp</hdiv:startPages>
    </hdiv:config>

</beans>
4

1 回答 1

4

您已在 hdiv-config.xml 中激活了 debugMode:

来自HDIV 参考文档

HDIV 提供调试执行模式,以便在生产环境中应用 HDIV,而不会出现任何功能或集成问题。换句话说,HDIV 处理并验证所有请求,但不会更改请求的原始执行,只是记录可能的攻击但不会停止它。

尝试禁用调试模式。

费尔南多·洛萨诺(HDIV 团队)

于 2015-12-11T08:59:10.437 回答