-
Notifications
You must be signed in to change notification settings - Fork 222
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
Unexpected response when requesting with multiple comma separated origins and wildcard AllowedOrigins #131
Comments
We can validate origin header yes. I don't see how this will pose backward compatible issue if we cover all formats browsers may send. |
I think the hard part is to cover all formats a browser may send. I don't think the change itself is breaking, but the risk of introducing a breaking change for some edge cases not correctly covered by the validation should be considered. Therefore it may be a good option to add a flag to disable the validation. Would you accept a PR? Do you have any expectations on how this validation should be implemented? |
Sure for PR. Expectation no dep, no regex, doesn't break :) |
@rs Out of curiosity, why do you insist on not relying on regexps? I do agree with you, but I'd like to understand your reasons. |
It's slow and unnecessary |
I'm a bit late to the party but,
Therefore, because no request issued from a Fetch-compliant browser can include the following header, Origin: https://github.com,https://test.example.com allowing However, I do believe that the range of origin patterns supported by rs/cors is too broad and easy to abuse; for instance, rs/cors supports
FWIW, some CORS libraries do parse or validate the value of the |
If an origin
https://*.example.com
is allowed and a client sends a request with a headerOrigin: https://github.com,https://test.example.com
the wildcard match is performed against the comma separated origin header value and succeeds.This leads to an unexpected and according to the specification invalid response header
Access-Control-Allow-Origin: https://github.com,https://test.example.com
. Also it was never intended thathttps://github.com
should be allowed.As far as I know current Browser implementations never send comma separated values in origin headers (and never multiple headers) and I'm not even sure if the specification would allow this. However, I think it would make sense to validate the origin header's format and reject requests with an unexpected format (not sure on how to do this backward compatible?).
The text was updated successfully, but these errors were encountered: