从karaf 4 pax-jetty中删除JSESSIONID httponly漏洞

问题描述 投票:0回答:1

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

首先尝试我在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。有人可以通过正确的方式来解决从卡拉夫4上运行的Pax-jetty中消除此漏洞的问题吗?

谢谢

java spring-mvc security jetty karaf
1个回答
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 =真

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

© www.soinside.com 2019 - 2024. All rights reserved.