-
Notifications
You must be signed in to change notification settings - Fork 30
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
Fix * behavior to not create CORS vulnerability footgun. #6
Conversation
When a user specifies *, then * should be returned by the server in the access-control-allow-origin header, not the origin header. All implementations of the CORS standard that reflect the origin header when * is specified are incorrect, because an Access-Control-Allow-Origin header of '*' has a different meaning than a reflected Origin header. Refer to Section 6.1 https://www.w3.org/TR/cors/. When * is set, Credentials are not allowed to be used in an authenticated request. **What's the big deal?** If you set Allow Credentials to True and Origins to * with this library then you have turned off SAMEORIGIN policy for your website, which is unexpected behavior and....really bad.
Upstream merged a fix: rs/cors#57 !! |
Thanks for the contribution! We will review as soon as possible. |
Part of Section 6.1 https://www.w3.org/TR/cors/ that applies to this case:
Based on that reflecting Both On the other hand your pull request would reverse it: |
It's standards compliant, but when I configure my CORS library for Before this PR I updated the title for you =] |
1 & 2 are showstoppers for me. |
I'm sorry but the list of CVEs and vulnerabilities the behavior causes is very very long... You're arguing for less security... You can still turn off SAMEORIGIN policy using the
If you want a list of some places that similar logic has caused security issues.
Quite frankly, CORS is really confusing and most people don't know the difference between Additionally to address To top it off, there's no way to return No idea how you could be against this PR tbqh... |
Does it break compliance with the standard you're referring to in the pull request description? Was the package compliant with that standard before your pull request? Does it remove support for a behavior that is allowed by standard, supported by browsers and used in the real world? Does it introduce a breaking change for those relying on this valid behavior? Does it offer any way of reverting to the old behavior via a setting if you need it? This change is not a clear win you describe it to be. I removes functionality and standard compliance because it can introduce a security vulnerability if misconfigured |
Lol... Man. Open source is a hoot. |
I suggested alternative solution that wouldn't break standard compliant behavior that has real world use. I would know, I'm in real world and I use it :P Your answer is that I'm arguing for less security. |
Still no decision? |
ping @ejcx |
@hazcod what's the question for me? I'm not the maintainer of go-chi/cors |
Sorry, pinging @VojtechVitek |
Hey all, I've opted to take the security advice from @ejcx as this is a common and dangerous mistake. I've also taken the lead from the original author of this middleware at github.com/rs/cors -- if someone wants to allow a wildcard of origins and return that origin name, they should use the Resolved in b978ea8 |
When a user specifies *, then * should be returned by the server in
the access-control-allow-origin header, not the origin header.
All implementations of the CORS standard that reflect the origin header
when * is specified are incorrect, because an Access-Control-Allow-Origin
header of '*' has a different meaning than a reflected Origin header. Refer
to Section 6.1 https://www.w3.org/TR/cors/. When * is set, Credentials
are not allowed to be used in an authenticated request.
What's the big deal?
If you set Allow Credentials to True and Origins to * with this library
then you have turned off SAMEORIGIN policy for your website, which is
unexpected behavior and....really bad.