Skip to content

Enumerable cross-origin properties don't seem to be web-compatible #3183

Closed

Description

@bzbarsky

Updating Firefox to #2777 caused a web compat issue: if a cross-origin window makes its way into jQuery.extend, that function will go into an infinite loop. This is turning up as a problem on actual sites. See https://bugzilla.mozilla.org/show_bug.cgi?id=1412741 for details.

I will be backing out the corresponding changes from Firefox.

Activity

  1. bzbarsky commented on Oct 31, 2017

    @bzbarsky
    ContributorAuthor
  2. bzbarsky commented on Oct 31, 2017

    @bzbarsky
    ContributorAuthor

    And @cdumez because he was working on this stuff in WebKit...

  3. cdumez commented on Oct 31, 2017

    @cdumez

    I may be able to reproduce in WebKit ToT. No infinite loops but login fails and I get this error in console:
    RangeError: Maximum call stack size exceeded.

  4. bzbarsky commented on Oct 31, 2017

    @bzbarsky
    ContributorAuthor

    Right, I should have said "infinite recursion", not "infinite loop". In Gecko the infinite recursion didn't run out of stack space in the amount of time I was willing to wait...

  5. domenic commented on Oct 31, 2017

    @domenic
    Member

    We'll try to fix this ASAP. Sorry to put everyone through this.

    To help us understand: this problem would also occur with a same-origin window, right? It's just bad luck that the code in question is only passing cross-origin windows and expecting them to work?

  6. bzbarsky commented on Oct 31, 2017

    @bzbarsky
    ContributorAuthor

    To help us understand: this problem would also occur with a same-origin window, right?

    No, because the recursive step in jQuery.extend only happens for things that test true for Array.isArray or jQuery.isPlainObject. And jQuery.isPlainObject is false for same-origin windows (not least because toString.call( obj ) !== "[object Object]" returns true). But it's true for cross-origin windows, because that test returns false and the object has a null proto. See https://code.jquery.com/jquery-3.2.1.js around line 300.

    The problem would occur with an object graph that contains plain objects, has loops, and has non-writable properties so the loops don't get broken by extend() as it traverses the object graph...

  7. bzbarsky commented on Oct 31, 2017

    @bzbarsky
    ContributorAuthor

    Note that after the backout, Firefox will go back to its previous behavior: indexed properties will be enumerable, but other things will not.

  8. annevk commented on Nov 1, 2017

    @annevk
    Member

    @bzbarsky but other things would still be enumerable on same-origin objects, right?

  9. bzbarsky commented on Nov 1, 2017

    @bzbarsky
    ContributorAuthor

    Yes, everything will remain as it was for same-origin objects.

  10. cdumez commented on Nov 1, 2017

    @cdumez

    Will back out change from WebKit as well (https://bugs.webkit.org/show_bug.cgi?id=179117).

  11. added a commit that references this issue on Nov 2, 2017
    53a0334
  12. added a commit that references this issue on Nov 6, 2017
    ad88237
  13. added a commit that references this issue on Jan 8, 2019
    5091805
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions