• 基于Tomcat 的WEB Project存在的安全漏洞总结


    1 检查工具:Acunetix Web Vulnerability Scanner V9破解版

    2 检查漏洞说明结果显示:

    2.1 HTML Form Without CSRF Protection

    2.2 slow_Http_DoS

    2.3  If possible, you should set the Secure flag for this cookie

    2.4 If possible, you should set the HTTPOnly flag for this cookie

    如下图:

    3 安全漏洞解决办法

    3.1 HTML Form Without CSRF Protection 解决方案:

    情况说明,CSRF一般发生在表单Login、登录提交时,处理过程大体上可以总结为在Login.jsp页面上随机产生一个字符串,Set到会话Session内自定义的变量,

    然后在Form表单内隐藏一个存放此值的input ytpe ="hidden" 的元素,即可:即如下:

    *****Login.jsp********

    <%@page import="Java.util.UUID"%> 
    <%

    //deal with CSRF
    String uuid = UUID.randomUUID().toString().replaceAll("-", "");
    request.getSession().setAttribute("randTxt",uuid);

    %>

    <form id="welcomeAction_login" name="login"  action="welcomeAction_login.do"   method="POST">

    ....

    <input type="hidden" name="randSesion"  value = "<%=request.getSession().getAttribute("randTxt")%>" />    
    ......

    </form>

    注意:表单提交时Form头处一定要写上:action="welcomeAction_login.do"   method="POST",否则会引出其它相关中级的问题

    3.2 slow_Http_DoS解决方案:

    原理:通过并发连接池进行的慢速读攻击(基于TCP持久时间)等。慢速攻击基于HTTP协议,通过精心的设计和构造,这种特殊的请求包会造成服务器延时,而当服务器负载能力消耗过大即会导致拒绝服务

    解决方案:
    1 设置Tomcat / server.xml文件    connectiontimeout 值,默认为20000ms,修改为8000ms(Tomcat 自身安全漏洞)

    2 设置AJAX的全局timeout时间(默认为30000ms) $.ajaxSetup({timeout:8000});

    3.3  If possible, you should set the Secure flag for this cookie,set the HTTPOnly flag for this cookie解决方案:
    1 (Tomcat 自身安全漏洞)设置设置Tomcat / web.xml文件:

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

    2 在Login .jsp主页面加入:
    response.setHeader("SET-COOKIE", "JSESSIONID=" + sessionid + "; secure ; HttpOnly");


    4 ******涉及内容和网站:

    1 CSRF科普   http://www.cnblogs.com/hyddd/archive/2009/04/09/1432744.html

    2 CSRF一种解决办法:http://jingyan.baidu.com/album/597a0643671e6a312b524305.html

    3 set the Secure flag for this cookie:  https://www.owasp.org/index.PHP/SecureFlag

    4 set the HTTPOnly flag for this cookie:  http://coffeesweet.iteye.com/blog/1271822

  • 相关阅读:
    java.lang.ClassNotFoundException: org.jaxen.JaxenException
    hdu 4882 ZCC Loves Codefires(贪心)
    C++ STL 源代码学习(之deque篇)
    算法导论学习笔记(2)-归并排序
    机器学习方法:回归(一):线性回归Linear regression
    HDU 2028 Lowest Common Multiple Plus
    C++11新特性应用--实现延时求值(std::function和std::bind)
    大数减法
    hive 运行sqlclient异常
    Oracle 12c agent install for windows
  • 原文地址:https://www.cnblogs.com/antyi/p/7128372.html
Copyright © 2020-2023  润新知