-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Replace CSRF cookie with CrossOriginProtection
#36183
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
base: main
Are you sure you want to change the base?
Conversation
CrossOriginProtection
CrossOriginProtectionCrossOriginProtection
|
Test failures need investigation. I think I was quite thorough with this removal, |
|
Unexpectedly, the fix in 1eb058d worked to fix the last issue. I think there may be a underlying bug why this test is sensitive to a |
tests/integration/csrf_test.go
Outdated
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.
Maybe use a new test for CrossOriginProtection
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.
Yes I would still like to add a integration test that leverages Sec-Fetch-Site to validate this protection.
"breaking" usually means end users or site admins must do something, or experience something totally different. But for this one, I think it isn't really "breaking". WDYT? And, the TODOs are not necessary (or, we shouldn't "add additional trusted origins", there is no such use case) |
Not right, see below |
|
Yeah I think we can go strict and have it enabled on all endpoints. If issues arise, we can think about solutions. |
|
Done in da28335, now it's always enabled unconditionally. |
Wait, it will cause problems with CORS, according to AI:
So we still need to disable CrossOriginProtection for the CORS endpoints.
|
|
For the record, if there are issues, COP offers 2 ways to disable it conditionally:
Both could be made configurable, if needed. |
I'm not sure but yes sounds plausible that CORS is an exception. |
|
I've re-added |
|
I think combining these two options is still not good because those route groups also match on non-CORS requests but we probably only want to disable the protection when the request was identified as CORS, e.g. when |
Leave for a while. The current logic isn't right.
This reverts commit 1e89768.
|
I think the cors handler could indicate in the request context that it had a match with a boolean flag, and then the COP handler could act on that flag and be disabled. |
|
I'm not sure your AI answer is right. Go's protection relies on So I'd lean towards having all endpoints protected, without exception. Restrictions can be relaxed later if issues are demonstrated. I will push again the full strict settings. |
This reverts commit 4b77d13.
See my comment above. "CrossOriginProtection" must accept (trust) that origin, if I understand correctly. |
|
I've read a bit more on these topics, these seem like good resources: https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html From what I gather, these header checks alone are not recommended, but header checks combined with a SameSite cookie (lax or strict) is recommended as adequate protection. |



Removes the CSRF cookie in favor of
CrossOriginProtectionwhich relies purely on HTTP headers.Fixes: #11188
Fixes: #30333
Helps: #35107
TODOs: