-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
🚀 [Feature]: stop dangerously bypassing the wildcard exception (CORS) #2338
Comments
Thanks for opening your first issue here! 🎉 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord |
Thx for the report |
I'd love to take a shot at this! |
Using a default config of |
thanks and already assign you |
Feature Description
Fiber's CORS middleware actively bypasses the so-called wildcard exception: if developers configure their CORS middleware to allow credentials and specify the wildcard as an allowed origin, the resulting middleware unconditionally reflects the value of the request's
Origin
header in theAccess-Control-Allow-Origin
response header.This is insecure insofar as it exposes users to cross-origin attacks that can be mounted from any origin.
For information, a similar issue was reported to (and subsequently fixed by) other Web frameworks/libraries:
Additional Context (optional)
Steps to reproduce
mkdir wildcardcraziness && cd $_
.main.go
.go mod init whatever && go mod tidy
.go run main.go
.curl -sD - -o /dev/null -H "Origin: https://attacker.org" localhost:8081/hello
.Expected behaviour
Perhaps the following:
curl -sD - -o /dev/null \ -H "Origin: https://attacker.org" \ localhost:8081/hello
Ideally, though, the resulting middleware should not be built at all, since it is dysfunctional. More about this in my latest blog post.
Actual behaviour
curl -sD - -o /dev/null \ -H "Origin: https://attacker.org" \ localhost:8081/hello
Note the unconditional reflection of the request's
Origin
header value (https://attacker.org
) in theAccess-Control-Allow-Origin
response header.Code Snippet
Checklist:
The text was updated successfully, but these errors were encountered: