Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
zhouyx opened this issue Feb 13, 2019 · 7 comments
Closed

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

zhouyx opened this issue Feb 13, 2019 · 7 comments

Comments

@zhouyx
Copy link
Contributor

zhouyx commented Feb 13, 2019

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

@aghassemi
Copy link
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.

@twifkak
Copy link
Member

twifkak commented May 8, 2019

cc @ampproject/wg-caching

@twifkak
Copy link
Member

twifkak commented May 8, 2019

@twifkak
Copy link
Member

twifkak commented May 8, 2019

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.

@dfabulich
Copy link

dfabulich commented Aug 2, 2019

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?

@cramforce
Copy link
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.

@stale
Copy link

stale bot commented Aug 5, 2021

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.

@stale stale bot added the Stale Inactive for one year or more label Aug 5, 2021
@stale stale bot closed this as completed Aug 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants