利用ASP.NET中的x-up-devcap-post-charset请求头绕过Web防火墙

iso60001  1787天前

22.png

以前我发表过几篇利用编码技术绕过WAF的文章。在文章中我不仅介绍了绕过WAF的方法,还明确指出WAF产品可以通过拦截特定的字符集或者只允许在Content-Type中使用白名单中的charset来使绕过方法无效。

而又经过一段时间的研究后,我又在ASP.NET中找到了一个用来绕WAF的请求头x-up-devcap-post-charset,它可以用来代表charset,这样就可以绕过WAF对Content-Type请求头的检测保护机制。

现在就让我正式介绍x-up-devcap-post-charset,使用样例如下:

POST /test/a.aspx?%C8%85%93%93%96%E6%96%99%93%84= HTTP/1.1
Host: target
User-Agent: UP foobar
Content-Type: application/x-www-form-urlencoded
x-up-devcap-post-charset: ibm500
Content-Length: 40

%89%95%97%A4%A3%F1=%A7%A7%A7%A7%A7%A7%A7

如上所示,Content-Type请求头中没有charsetx-up-devcap-post-charset表明了编码使用的字符集。此外,为了告诉ASP.NET注意这个新的请求头,User-Agent的值需要以UP作为开头!

上述请求中的被编码的参数我是通过Burp Suite HTTP Smuggler自动生成的,原始请求如下:

POST /testme87/a.aspx?HelloWorld= HTTP/1.1
Host: target
User-Agent: UP foobar
Content-Type: application/x-www-form-urlencoded
Content-Length: 14

input1=xxxxxxx

我之所以会发现这个特殊的请求头,是我在ASP.NET的框架代码中寻找其他东西时无意发现的。以下是ASP.NET中和这个请求头有关的一段代码,它展示了ASP.NET在查看Content-Type中的charset之前如何读取内容编码:

https://github.com/Microsoft/referencesource/blob/3b1eaf5203992df69de44c783a3eda37d3d4cd10/System/net/System/Net/HttpListenerRequest.cs#L362

33.png

以及

https://github.com/Microsoft/referencesource/blob/08b84d13e81cfdbd769a557b368539aac6a9cb30/System.Web/HttpRequest.cs#L905

44.png

我觉得我发现的这个编码绕过技术应该适用于大多数WAF,因为我感觉它们没有认真对待这个绕过技术。当然,OWASP ModSecurity核心规则集(CRS)很快就会为它创建一个专门的过滤规则。在我发布这篇文章之前,已经向CRS的Christian Folini(@ChrFolini)展示了技术细节。新规则将出现在https://github.com/SpiderLabs/owasp-modsecurity-crs/pull/1392

参考文献:

https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2017/august/request-encoding-to-bypass-web-application-firewalls/

https://www.slideshare.net/SoroushDalili/waf-bypass-techniques-using-http-standard-and-web-servers-behaviour

https://soroush.secproject.com/blog/2018/08/waf-bypass-techniques-using-http-standard-and-web-servers-behaviour/

https://www.nccgroup.trust/uk/about-us/newsroom-and-events/blogs/2017/september/rare-aspnet-request-validation-bypass-using-request-encoding/

https://github.com/nccgroup/BurpSuiteHTTPSmuggler/

感谢你的阅读!

本文由白帽汇整理并翻译,不代表白帽汇任何观点和立场
来源:https://soroush.secproject.com/blog/2019/05/x-up-devcap-post-charset-header-in-aspnet-to-bypass-wafs-again/

最新评论

昵称
邮箱
提交评论