【问题标题】:Removing JSESSIONID httponly vulnerability from karaf 4 pax-jetty从 karaf 4 pax-jetty 移除 JSESSIONID httponly 漏洞
【发布时间】:2017-12-18 17:09:00
【问题描述】:

我正在尝试从运行嵌入式码头的 karaf 服务器中删除 httponly cookie 漏洞。 java应用程序是基于spring MVC的,使用spring security 3.2.10.RELEASE。我尝试了一些不同的事情但没有成功。

第一次尝试我在 web.xml 上添加了以下内容,但没有成功

<?xml version="1.0" encoding="UTF-8"?>

<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" metadata-complete="true">


    <session-config>
        <tracking-mode>COOKIE</tracking-mode>
        <session-timeout>30</session-timeout> <!-- in minutes -->
        <cookie-config>
            <secure>true</secure>
            <http-only>true</http-only>
        </cookie-config>
    </session-config>

    <!-- Spring Config Files -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/spring-security.xml
            /WEB-INF/webmodule-mvc-dispatcher-servlet.xml
        </param-value>
    </context-param>

    <context-param>
        <param-name>blueprintLocation</param-name>
        <param-value>/WEB-INF/blueprint/blueprint.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <!--listener>
        <listener-class>org.apache.aries.blueprint.web.BlueprintContextListener</listener-class>
    </listener-->


    <!-- Spring MVC WEB Servlet -->
    <servlet>
        <servlet-name>webmodule-mvc-dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

第二次尝试我在 WEB-INF/jetty-web.xml 上添加了以下代码,但没有成功。

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Get name="sessionHandler">
        <Get name="sessionManager">
            <Set name="httpOnly" type="boolean">true</Set>
            <Set name="secureCookies" type="boolean">true</Set>
        </Get>
    </Get>
</Configure>

第三次尝试我在 karaf 目录的 /etc/jetty.xml 中添加了以下代码。

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    <Get name="sessionHandler">
        <Get name="sessionManager">
            <Set name="httpOnly" type="boolean">true</Set>
            <Set name="secureCookies" type="boolean">true</Set>
        </Get>
    </Get>
</Configure>

在所有三个尝试中,jetty 似乎都忽略了这个配置,因为 JSESSIONID cookie 仍然没有显示为安全和 httponly。有人可以对在 karaf 4 上运行的 Pax-jetty 消除此漏洞的正确方法有所了解吗?

谢谢

【问题讨论】:

  • 您使用的是哪个版本的 servlet 规范?由于此功能仅在 Servlet 3.0 中引入(旧版本的规范不支持此 cookie-config)
  • 您好,感谢您的宝贵时间,我使用的是 servlet 3.0.1
  • "Servlet 3.0.1" 不是规范版本,而是工件版本(不同的东西)。您的 webapp 有一个 WEB-INF/web.xml,它指定了您的 webapp 声明为的 servlet 规范的特定版本。
  • 抱歉造成误会。我发布了完整的 web.xml 标头。java.sun.com/xml/ns/javaee" xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:schemaLocation ="java.sun.com/xml/ns/javaeejava.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0" metadata-complete="true">

标签: java spring-mvc security jetty karaf


【解决方案1】:

经过大量研究,我在 RedHat 的以下帖子中找到了解决方案

https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.3/html/security_guide/webconsole

基本上需要在 /etc/org.ops4j.pax.web.cfg 文件中定义以下属性。

org.ops4j.pax.web.session.cookie.httpOnly=true

org.osgi.service.http.secure.enabled=true

【讨论】:

  • 尚不清楚如果码头在负载均衡器或处理 https 的反向代理后面提供 http 请求,这是否有效
猜你喜欢
  • 2012-10-09
  • 1970-01-01
  • 2014-08-01
  • 1970-01-01
  • 2021-07-08
  • 2016-02-28
  • 1970-01-01
  • 2012-12-12
  • 2011-07-22
相关资源
最近更新 更多