W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2009

[whatwg] Small ddition to 7.4.2.1, postMessage's security considerations for authors

From: Jeff Walden <jwalden+whatwg@MIT.EDU>
Date: Sat, 14 Feb 2009 01:48:53 -0800
Message-ID: <49969385.6070803@mit.edu>
The spec should mention that even after MessageEvent.origin's value has been checked, MessageEvent.data should also be checked for structural correctness, because if the target window contains an XSS hole, improper validation of incoming messages could result in the target window's XSS hole being propagated into the sender's window as well.

For example, consider a site A which requests a particular string of JSON data from site B, which it then parses into an object using eval().  If site B is subvertible, the response JSON string may instead be arbitrary script which would be executed by site A *as* site A's code.  Proper validation by site A would mean checking that the sent string actually is JSON and not arbitrary syntactically-correct JavaScript.

(Ignore the fact that the site shouldn't be unserializing JSON data using eval(), and further ignore that structured data-passing makes this particular use obsolescent.  Other instances of contamination may be possible depending on the sent data and its structure, and this was just the simplest example to explain.)

Jeff
Received on Saturday, 14 February 2009 01:48:53 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:09 UTC