【问题标题】:Setting 'HttpOnly' and 'Secure' in web.xml在 web.xml 中设置 'HttpOnly' 和 'Secure'
【发布时间】:2017-11-17 02:13:15
【问题描述】:

我需要将 'HttpOnly' 和 'Secure' 属性设置为 'true' 以防止 CWE-614: Sensitive Cookie in HTTPS Session Without 'Secure' AttributeCWE-402: Transmission of Private Resources into a New Sphere 缺陷出现在 Veracode 报告中。

网上搜索了一下,似乎最好的办法就是简单的在项目的web.xml文件中设置属性如下:

<session-config>
    <cookie-config>
        <http-only>true</http-only>
        <secure>true</secure>
    </cookie-config>
 </session-config>

但是,我在开始标记上收到一条错误消息,提示 “元素类型“session-config”的内容必须匹配“(session-timeout)?”.

我不确定这到底是什么意思。我猜它与元素的顺序有关,但我真的不知道如何解决它。

有什么想法吗?

谢谢!

【问题讨论】:

    标签: security session cookies web.xml httponly


    【解决方案1】:

    仅在 http-servlet 规范 3 中提供对安全和仅 http 属性的支持。检查 web.xml 中的版本属性是否为“3.0”。

    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
                http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
    

    【讨论】:

      猜你喜欢
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-30
      • 2013-04-10
      • 2021-08-01
      • 2021-11-10
      相关资源
      最近更新 更多