amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

iOS Safari v13.4 amp-access-iframe ITP issue

Open gremz opened this issue 6 years ago • 3 comments

What's the issue?

Safari introduced further changes to ITP (Intelligent Tracking Prevention) implementation, at this point fully blocking Third-Party cookies on iOS Safari starting with v13.4. https://webkit.org/blog/10218/full-third-party-cookie-blocking-and-more/

The issue introduces issues to these newer version of Safari when using the amp-access-iframe-api. The iframe is now unable to access storage from the primary site used to access things such as logged in/subscription status.

How do we reproduce the issue?

An example of this issue can be seen at https://jsbin.com/vehegosode/edit?html,js,output. This can be replicated on a iOS device w/ v13.4.x installed.

  1. Visit https://gremz.github.io/gremiasz-home/examples/set_cookie.html
  2. Click the Set Cookie button (simulating a login) and confirm Current cookies: test_cookie=true is shown
  3. Visit https://output.jsbin.com/vehegosode and notice you get the text paywall. Indicating the cookie was not able to be read.

The iframe checks to see if the cookie exists in the iframe, if it doesn't then the paywall is shown.

What browsers are affected?

iOS Safari v13.4 and above

Which AMP version is affected?

This a new issue, this implementation is working on older versions (< v13.4) of iOS Safari. Tested against AMP version 2004240001480.

gremz avatar Apr 29 '20 20:04 gremz

Note that this is also reproducible on MacOS Safari starting from 13.1 (which makes it easier to debug). To get a realistic test on an actual AMP page, you must view the page on a google.com surface (or another site differing from the iframe's), e.g. url starting with https://www.google.com/amp/s/... so that the iframe is actually 3rd party.

It may not be possible to fix this directly. Safari forbids both reading & writing cookies in a 3rd party context. One potential savior is the Storage Access API but that requires user interaction to be triggered, and the user has to grant the access request.

The indirect workaround would be to somehow associate the READER_ID with whatever cookie value you intended to use.

kliuless avatar Jun 30 '20 23:06 kliuless

This appears to have been fixed starting with iOS Safari v14. Closing.

gremz avatar Nov 30 '20 18:11 gremz

I'm still able to reproduce this. iOS 14 now applies the same restrictions to browsers other than Safari.

See this Webkit report: https://bugs.webkit.org/show_bug.cgi?id=218396

On the google.com/amp surface, a couple things are relevant to ITP:

  • the amp-access-iframe provided by the publisher is nested in an iframe 2-levels deep. All 3 levels have different origins. If it were only nested 1 level, there's a temporary workaround where interacting w/ the login popup gives storage access to the iframe.
  • the intermediate iframe doesn't even have the same TLD as the amp-access-iframe, because google is using a CDN to "proxy" the publisher's article.

The only solutions I can see are:

  • google changing the AMP framework so the publisher's origin is used for all 3 levels of frames (but that may not work if the access-iframe has the same TLD but is a different subdomain - the origin being different)
  • using the readerID so the iframe can identify the user (this was the approach suggested by a Google developer)

kliuless avatar Dec 04 '20 20:12 kliuless