Loading ...
Sorry, an error occurred while loading the content.

251Re: ADsafe and bind

Expand Messages
  • brendaneich
    Sep 8, 2008
      --- In caplet@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
      > --- In caplet@yahoogroups.com, "marcel.laverdet" <marcel@> wrote:
      > Thanks, Marcel, that was really helpful. ADsafe's mozilla function is
      > now conditioned on the existence of slots for concat, filter, map,
      > reverse, slice, and sort.
      > I haven't found the leak in forEach. How does that one work?

      These vulnerabilities were first pointed out by Jeff Walden and Eli
      Friedman, then interns at Mozilla, in August 2007. Jeff wrote back
      then in reply to Marcel:

      "... you need only call it on something that has a length property (or
      a getter that doesn't throw), and so long as your provided function
      *is* one, it'll get called for each item less than the pre-computed
      length. Here's an example:


      <a onclick="boom();">click here</a>

      function boom()
      var win = null;
      var forEach = [].forEach;
      forEach(function(val, prop, thisp) {
      win = thisp;
      }, []);
      win.alert("Hello world!");



      Aha, but that doesn't work, and for a simple enough reason: the test
      console page (presumably you used this) doesn't have any subframes,
      iframes, etc. Consequently, |window.length == 0| and there's nothing
      to iterate over, so the callback is never called. However, it's a
      reasonably safe bet that most Facebook pages *will* contain iframes
      for ads, and with an iframe in the document it'll succeed. To
      demonstrate this, simply run the following URL on the test console
      after loading the given example:

      javascript:var d = document;

      Before I load that, the exploit fails. After I load it, it succeeds.



      Separately, Eli wrote:

      "Some other methods that are also vulnerable: Array.prototype.reverse,
      Array.prototype.sort, Array.prototype.forEach (returns this in Safari 2
      only), and Object.prototype.valueOf.

      Also, combined with Array.prototype.push or Array.prototype.unshift or
      the existence of a subframe, a similar vulnerability exists with
      Array.prototype.forEach, Array.prototype.every, Array.prototype.map,
      Array.prototype.some, Array.prototype.reduce (Fx 3 only),
      Array.prototype.reduceRight (Fx 3 only), and Array.prototype.filter.


      So scrutinize all of the array extras, not just forEach, map, and filter.

      HTH, and credit where due.

    • Show all 13 messages in this topic