HDIV:HDIV_PARAMETER_NOT_EXISTS 时不重定向到错误页面

HDIV : not redirecting to errorpage when HDIV_PARAMETER_NOT_EXISTS

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

令牌_HDIV_STATE_被注入每个页面,link.. 因此,为了测试它是否按预期工作以抵御 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>

您在 hdiv-config.xml:

中激活了调试模式

来自HDIV Reference Documentation

HDIV offers a debug execution mode in order to apply HDIV in production environments without any functional or integration problems. In other words HDIV process and validates all the requests but doesn't change original execution of the request, just logging the possible attack but without stopping it.

尝试禁用调试模式。

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