craftcms / cms

Build bespoke content experiences with Craft.
https://craftcms.com
Other
3.28k stars 637 forks source link

CSRF Issue in iOS / Mobile Safari — unable to verify your data submission #9637

Open codyjames opened 3 years ago

codyjames commented 3 years ago

Description

We get quite a few "unable to verify your data submission" CSRF errors on our site (50-100 a day). We've got around ~7k users logging in and doing things. Almost all of these happen on Mobile Safari. We even switched from CSRF cookies to session with no luck.

Note that it doesn't happen for every mobile safari user — but it happens enough that it's an issue.

Here is a screenshot of the error in our Sentry account:

Screen Shot 2021-07-23 at 1 48 35 PM

Steps to reproduce

  1. Have a site with a lot of users/forms.
  2. 50-100 times a day you'll get "unable to verify your data submission" errors from users using Mobile Safari.

Additional info

codyjames commented 3 years ago

Some similar issues on other platforms:

brandonkelly commented 3 years ago

Guessing this is environmental. Can you please email support@craftcms.com about this? We can help you look into it from there.

remcoov commented 1 year ago

Any updates on this? We have the same problem.. lot's of 'unable to verify your data submission'.

codyjames commented 1 year ago

@remcoov I was unable to resolve it. Still get quite a few of these errors for folks on Mobile Safari. Let me know if you end up finding a solution though!

remcoov commented 1 year ago

Yeah, we're not only getting this on Mobile Safari. Just curious, how do you handle this for the user?

angrybrad commented 1 year ago

Just a theory, but try setting https://craftcms.com/docs/4.x/config/general.html#requirematchinguseragentforsession to false - session is taken into account for CSRF tokens, and maybe mobile Safari is changing their user agency string frequently.