【问题标题】:HDIV : not redirecting to errorpage when HDIV_PARAMETER_NOT_EXISTSHDIV:当 HDIV_PARAMETER_NOT_EXISTS 时不重定向到错误页面
【发布时间】:2015-12-11 16:59:10
【问题描述】:

我正在尝试通过使用 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>

【问题讨论】:

    标签: java struts hdiv


    【解决方案1】:

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

    来自HDIV Reference Documentation

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

    尝试禁用 debugMode。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-11
      • 2020-05-05
      • 2010-12-16
      • 2014-05-15
      • 2013-07-07
      • 1970-01-01
      • 2011-12-24
      相关资源
      最近更新 更多