HTTP响应拆分

时间:2020-03-06 15:04:19  来源:igfitidea点击:

即时通讯试图处理这种可能的利用,并想知道最好的方法是什么?我应该使用apache的common-validator并创建已知允许符号的列表并使用它吗?

解决方案

从维基百科文章:

The generic solution is to URL-encode strings before inclusion into HTTP headers such as Location or Set-Cookie.
  
  Typical examples of sanitization include casting to integer, or aggressive regular expression replacement. It is worth noting that although this is not a PHP specific problem, the PHP interpreter contains protection against this attack since version 4.4.2 and 5.1.2.

编辑

im tied into using jsp's with java actions!

似乎没有针对此攻击媒介的任何基于JSP的保护,网络上的许多描述都假定是asp或者php,但是此链接描述了一种相当平台无关的方法来解决此问题(jsp作为其中的附带示例) 。

基本上,第一步是识别潜在危险字符(CR,LF等),然后将其删除。恐怕这是我们所希望的强大解决方案!

Solution
  
  Validate input. Remove CRs and LFs (and all other hazardous characters) before embedding data into any HTTP response headers, particularly when setting cookies and redirecting. It is possible to use third party products to defend against CR/LF injection, and to test for existence of such security holes before application deployment.

使用PHP? ;)

根据Wikipedia和PHP CHANGELOG的说法,PHP自4.4.2起在PHP4中提供保护,而自5.1.2起在PHP5中提供保护。

只是略读了-但是,这可能会有所帮助。他的示例是用JSP编写的。

好的,在读取字符串时,将类型强制转换为int并没有太多用处,在接收到来自浏览器的输入的每个操作中也都使用正则表达式,可能会很麻烦,我正在寻找更强大的解决方案