Skip to content

allow-same-origin iframe potential issue with signed exchange #20848

Closed

Description

@zhouyx

Based on the paragraph that @cramforce wrote, redirection within allow-same-origin iframe can easily create make the iframe a friendly iframe.

This won't happen for cached AMP pages because the iframe origin can never be the same as the cache origin. However what about the case with signed exchange?

cc @cramforce @Gregable @aghassemi @lannka @torch2424

Activity

  1. aghassemi commented on Feb 15, 2019

    @aghassemi
    Contributor

    @zhouyx yes, it is a problem. We are tracking a new feature request for Chrome where we "Ensure AMP frames can never mess with their parent (whether or not actually hosted on the same origin)." Some early discussions here: whatwg/html#2757

    Essentially unless we can detect a redirect origin change before the page has a chance to interact with parent ( I haven't tried to find a solution but looks unlikely ), this becomes a blocker for web packaging.

    To build on @zhouyx's point, allowing same-origin amp-iframe in the current state is technically equivalent to allowing <script async src=whatever> in AMP.

  2. twifkak commented on May 8, 2019

    @twifkak
    Member

    cc @ampproject/wg-caching

  3. twifkak commented on May 8, 2019

    @twifkak
    Member

    Quick note that "iframe origin can never be the same as the cache origin" is not true; redirect can evade that too. But cache prevents that resource from being too much of a problem for the unsigned case.

  4. dfabulich commented on Aug 2, 2019

    @dfabulich

    I was thinking about this bug today, and I think a workaround might be possible without adding a new feature to the web platform.

    What if the AMP SXG validator required the SXG to have a Content-Security-Policy frame-src explicitly allowing all and only the origins of its <amp-iframe> elements?

    That way, a www.example.com SXG could have an <amp-iframe> pointing to iframe.example.com, but that iframe would be forbidden to navigate back to www.example.com and thereby become friendly, because CSP would prevent iframes from www.example.com; it would only allow unfriendly iframes from iframe.example.com.

    Would that work?

  5. cramforce commented on Aug 2, 2019

    @cramforce
    Member

    I think a problem with such an approach is that it can be extremely difficult to enumerate iframe origins.

    In general, AMP would really like to allow same-origin iframes. It also wants to avoid them scripting the parent. Not for security or compliance reasons, but because it would break on the cache in unexpected ways, and AMP aims to avoid documents breaking on the cache in unexpected ways.

    That is also why we've so far ignored the "redirect hack" that was always possible for on-origin AMP docs since it wasn't about security, but rather the hosting invariant.

  6. stale commented on Aug 5, 2021

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

  7. added
    Stale
    on Aug 5, 2021
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