-
Notifications
You must be signed in to change notification settings - Fork 25.2k
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
Update anti-request-forgery.md #34449
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments.
Consider alternative CSRF protection patterns if this poses an issue. | ||
Multiple tabs logged in as different users, or one logged in as anonymous, are not supported. | ||
|
||
With the Synchronizer Token Pattern, only the most recently posted page is guaranteed to contain a valid antiforgery token. Apps that wish to support multiple tabs should test supported browsers and log failures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this (line 164) statement is true; a fresh token is indeed created for each page request, but the token is validated against a security token stored in a cookie which is reused on all requests after it has initially been populated and is only changed upon changing identity.
Identity is to be understood in the broadest sense, i.e., anonymous is considered a form of identity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarification: "[...] the most recently posted page is guaranteed to contain a valid antiforgery token" is not untrue, but may give the impression that using multiple tabs is a problem, which it really isn't as stated above.
With the Synchronizer Token Pattern, only the most recently loaded page is guaranteed to contain a valid antiforgery token. Apps that wish to support multiple tabs should test supported browsers and log failures. ***Using multiple tabs can be problematic***. For example, if a user opens multiple tabs, requests made from previously loaded tabs might fail with an error: `Antiforgery token validation failed. The antiforgery cookie token and request token do not match` | ||
|
||
Consider alternative CSRF protection patterns if this poses an issue. | ||
Multiple tabs logged in as different users, or one logged in as anonymous, are not supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider scrapping the "Multiple browser tabs and the Synchronizer Token Pattern" section altogether.
I don't see why it would make sense to log in as one user, open another tab and log in as another user, and then expect the other tab to still be in a valid state, nor do I see how this would be specific to antiforgery tokens.
Fixes #25564
@Tobikblom please review
Internal previews