According to learn.microsoft.com ASP.NET core implements the Synchronizer Token Pattern to mitigate CSRF.
The Anti request forgery mechanism has many drawbacks impacting users:
ex 1: login page opened in 2 tabs
- Open the login page in two different tabs
- User A logs from Tab 1 (No issues)
- Without refreshing the Tab 2, user B tries to log in.
=> Produces a 400 page with AntiforgeryValidationException
ex 2: a form opened in 2 tabs (from the same link in a mail)
- Create a new Asp.Net Core MVC website from template (VS 2019)
- Create a new page which has a simple form which is validated with [ValidateAntiForgeryToken] on post.
- Email yourself a link to that page (I've used Gmail & Mailtrap)
- Open the link in two tabs by clicking on it normally
- Submit both forms in any order
=> The form which was opened FIRST produces a 400 error
It looks like SameSite=strict is an effective security measure against CSRF attacks
According to this article and this draft RFC, SameSite cookie seems an effective and robust security measure against CSRF attacks. ASP.NET Core 2.2's authentication cookie are configured with SameSite=strict. If my understanding is correct, authentication cookie are only sent to the server in a same-site navigation situation.
In my use case I trust the sub domains.
So if I can guarantee that my users are using a browser supporting the SameSite policy, is it safe to disable the anti CSRF mechanism of my ASP.NET Core application?