基於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解決方案
(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

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

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章