1

My company's website (mercury.co) sends password reset links via email to users. We ran into some really weird behavior that we can only reproduce in the Gmail iOS app relating to the SameSite Lax attribute:

  1. The user follows a link in their email to https://mercury.co/reset-password
  2. The browser loads Javascript from that URL to set up the site
  3. The client does a GET request, which returns a CSRF token in a cookie. This token has the SameSite Lax attribute set.
  4. Expected behavior: The client can read the cookie with the CSRF token in it. Actual behavior: The client cannot read the cookie. We've determined this by doing an alert(document.cookie) and seeing the CSRF token is not there when same-site lax is set, but is there when the same-site attribute is not set.

This causes the next POST request to fail because it can't get the CSRF token to be sent to the server. Though, if you look at the cookies that are sent in the request, it includes the cookie that has the CSRF token in it.

My understanding is that the cookie should be readable, because it is not cross-site in this context. And it certainly should not be unreadable, and then sent to the server on the next request.

My understanding is that SameSite Lax cookies should not prevent the client from reading this cookie.

As a fix, we've determined we don't need the SameSite Lax attribute on this particular cookie. However, we'd still like to understand the underlying cause of this issue.

Some details our investigation so far:

  • We can only reproduce the issue in the iOS Gmail app. We can't reproduce the issue by creating our own UIWebview or WKWebview (I ran in the iOS simulator for iOS 12.2). We can't reproduce it on the two iPads we tested on (though those are maybe different iOS versions). I tested on my iPhone running iOS 12.2
  • Based on using this method: https://stackoverflow.com/a/18678703/1176156 our application is not embedded in an iframe or anything when run in Gmail. We also disallow wrapping our site in an iframe via header.
MaxGabriel
  • 7,617
  • 4
  • 35
  • 82

2 Answers2

1

You mostly answered your own question (and pointed me in the right direction :-) ). For the sake of completeness, I found the relevant bug: Safari (still) doesn't send Lax cookies after a cross-site redirection.

This was fixed in release 77, which explains why the bug does not occur in iOS 12.3.1.

Niklas
  • 26
  • 3
0

As it turns out, this must have been a bug in iOS 12.2, because I can no longer reproduce this behavior in iOS 12.3.1. I can't find an iOS changelog detailed enough to show this fix, though, and I didn't find anything relevant in the Webkit changelog.

MaxGabriel
  • 7,617
  • 4
  • 35
  • 82