360网站安全检测中HTTP响应拆分漏洞的修复方法
4094 点击·0 回帖
![]() | ![]() | |
![]() | 360网站安全检测说实话真不咋滴,但是吧,检测一些不痛不痒的问题,但是鉴于某种种情况,面对问题还是要修复。360网站安全检测中有个HTTP响应拆分漏洞。描述: HTTP响应拆分漏洞,也叫CRLF注入攻击。CR、LF分别对应回车、换行字符。HTTP头由很多被CRLF组合分离的行构成,每行的结构都是“键:值”。如果用户输入的值部分注入了CRLF字符,它有可能改变的HTTP报头结构。 HTTP响应拆分是一个新的应用程序的攻击技术,使网页缓存中毒,跨用户涂改,如各种新的攻击,劫持用户的敏感信息和跨站点脚本(XSS)的网页。 危害: 攻击者可能注入自定义HTTP头。例如,攻击者可以注入会话cookie或HTML代码。这可能会进行类似的XSS(跨站点脚本)或会话固定漏洞。 思路: 限制用户输入的CR和LF,或者对CR和LF字符正确编码后再输出,以防止注入自定义HTTP头。 解决方案: 这种现象往往表现在带有参数传递的网页,只要合理的过滤好就OK啦,提供PHP代码: 1 $post = trim($post); 2 $post = strip_tags($post,""); //清除HTML如<br />等代码 3 $post = ereg_replace("\t","",$post); //去掉制表符号 4 $post = ereg_replace("\r\n","",$post); //去掉回车换行符号 5 $post = ereg_replace("\r","",$post); //去掉回车 6 $post = ereg_replace("\n","",$post); //去掉换行 7 $post = ereg_replace(" ","",$post); //去掉空格 8 $post = ereg_replace("'","",$post); //去掉单引号或者: ​ 1 $post = trim($post); 2 $post = strip_tags($post,""); //清除HTML如<br />等代码 3 $post = ereg_replace("\t","",$post); //去掉制表符号 4 $post = ereg_replace("\r\n","",$post); //去掉回车换行符号 5 $post = ereg_replace("\r","",$post); //去掉回车 6 $post = ereg_replace("\n","",$post); //去掉换行 7 $post = ereg_replace(" ","",$post); //去掉空格 8 $post = ereg_replace("'","",$post); //去掉单引号 | |
![]() | ![]() |