Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork6.3k
Replace CSRF cookie withCrossOriginProtection#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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
CrossOriginProtectionCrossOriginProtectionCrossOriginProtectionsilverwind commentedDec 17, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Test failures need investigation. I think I was quite thorough with this removal, |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
silverwind commentedDec 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Unexpectedly, the fix in1eb058d worked to fix the last issue. I think there may be a underlying bug why this test is sensitive to a |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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 forCrossOriginProtection
silverwindDec 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 leveragesSec-Fetch-Site to validate this protection.
wxiaoguang commentedDec 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
"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) |
silverwind commentedDec 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yeah it's more of a "nice to have" thing. No known use case exists for adding more origins. |
silverwind commentedDec 18, 2025
|
wxiaoguang commentedDec 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Because this review seems wrong#36183 (comment) And I made a mistake for the middlewares, now only |
wxiaoguang commentedDec 18, 2025
I think this PR doesn't fix 35107. 35107 needs an API |
silverwind commentedDec 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I wonder if it's even necessary to disable COP on any endpoints. It's only active for browsers and if browser headers are not present, the protection will just allow the request which means any API client will be unaffected.
|
silverwind commentedDec 18, 2025
It does fix the immediate issue, but I agree, what the autor really wants is a API to set up a mirror repo. Maybe we already have one? |
wxiaoguang commentedDec 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Not right, see below |
silverwind commentedDec 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Yeah I think we can go strict and have it enabled on all endpoints. If issues arise, we can think about solutions. |
silverwind commentedDec 18, 2025
Done inda28335, now it's always enabled unconditionally. |
wxiaoguang commentedDec 18, 2025
Wait, it will cause problems with CORS, according to AI:
So we still need to disable CrossOriginProtection for the CORS endpoints. ![]() |
silverwind commentedDec 18, 2025
For the record, if there are issues, COP offers 2 ways to disable it conditionally:
Both could be made configurable, if needed. |
silverwind commentedDec 18, 2025
I'm not sure but yes sounds plausible that CORS is an exception. |
silverwind commentedDec 18, 2025
I've re-added |
Uh oh!
There was an error while loading.Please reload this page.
silverwind commentedDec 18, 2025
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 |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Leave for a while. The current logic isn't right.
This reverts commit1e89768.
silverwind commentedDec 18, 2025
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. |
silverwind commentedDec 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 commit4b77d13.

Uh oh!
There was an error while loading.Please reload this page.
Removes the CSRF cookie in favor of
CrossOriginProtectionwhich relies purely on HTTP headers.Fixes:#11188
Fixes:#30333
Helps:#35107
TODOs: