
以前我發(fā)表過幾篇利用編碼技術繞過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請求頭中沒有charset,x-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
我之所以會發(fā)現這個特殊的請求頭,是我在ASP.NET的框架代碼中尋找其他東西時無意發(fā)現的。以下是ASP.NET中和這個請求頭有關的一段代碼,它展示了ASP.NET在查看Content-Type中的charset之前如何讀取內容編碼:
https://github.com/Microsoft/referencesource/blob/3b1eaf5203992df69de44c783a3eda37d3d4cd10/System/net/System/Net/HttpListenerRequest.cs#L362

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

我覺得我發(fā)現的這個編碼繞過技術應該適用于大多數WAF,因為我感覺它們沒有認真對待這個繞過技術。當然,OWASP ModSecurity核心規(guī)則集(CRS)很快就會為它創(chuàng)建一個專門的過濾規(guī)則。在我發(fā)布這篇文章之前,已經向CRS的Christian Folini(@ChrFolini)展示了技術細節(jié)。新規(guī)則將出現在[https://github.com/SpiderLabs/owasp-modsecurity-crs/pull/1392](https://github.com/SpiderLabs/owasp-modsecurity-crs/pull/1392)。
參考文獻:
https://github.com/nccgroup/BurpSuiteHTTPSmuggler/
感謝你的閱讀!
本文由白帽匯整理并翻譯,不代表白帽匯任何觀點和立場:https://nosec.org/home/detail/2556.html
來源:https://soroush.secproject.com/blog/2019/05/x-up-devcap-post-charset-header-in-aspnet-to-bypass-wafs-again/