1

I have a Rails/Ember one-page app. Burp reports that

The value of the 'content_type' JSON parameter is copied into the HTML document as plain text between tags. The payload da80balert(1)4f31e was submitted in the content_type JSON parameter. This input was echoed unmodified in the application's response.

I can't quite parse this message referring to "is copied into" and "was submitted" in, but basically what is happening is:

  1. A PUT or POST from the client contains ...<script>...</script>... in some field.
  2. The server handles this request, and sends back the created object in JSON format, which includes the string in question
  3. The client then displays that string, using the standard Embers/Handlebars {{content_type}}, which HTML-escapes the string and inserts it into the DOM, so the browser displays it on the screen as originally entered (and of course does NOT execute it).

So yes, the input was indeed echoed unmodified in the application's response. However, the application's response was not HTML, in which case there would indeed be a problem, but JSON, containing strings which when referred to by Handlebars will always be escaped properly for proper display in the browser.

So my question is, is this in fact a vulnerability? I have taken great care with my Ember app and can prove that no data from JSON objects is ever inserted "raw" into the DOM. Or is this a false positive given rise to by the mere fact the unescaped string may be found in the response if looked for using an unintelligent string comparison, not taking into account the fact that the JSON will be processed/escaped by the client-side framework?

To put it a different way, in a classic webapp spitting out HTML from the server, we know that user input such as the above must be escaped/sanitized properly. Unsanitized data "on the wire" in and of itself represents a vulnerability. However, in a one-page app based on JSON coming back from the server, the escaping/sanitization occurs in the client; the JSON on the "wire" may contain unsanitized data, and this is as expected. Am I missing something here?

4

1 回答 1

0

有一些巧妙的方法可以欺骗 IE9 及更早版本将 JSON 视为 HTML。所以即使服务器的响应有一个Application/json的Content-Type头,IE也会第二次猜到。这称为内容类型嗅探,可以通过添加 X-Content-Type-Options: nosniff 标头来禁用。JSON 不是可执行格式,因此您的理解是正确的。

我在 OWASP AppSec EU 2013 上关于保护单页网络应用程序的演讲中对这个确切的问题做了一个演示,有人在 youtube 上发布了这个问题:http://m.youtube.com/watch?v= Femsrx0m9bU

于 2014-04-20T05:55:37.657 回答