Skip to content
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

Wildcard support for AllowedHeaders or add AllowedHeadersFunc #179

Closed
kilgaloon opened this issue Jun 25, 2024 · 3 comments
Closed

Wildcard support for AllowedHeaders or add AllowedHeadersFunc #179

kilgaloon opened this issue Jun 25, 2024 · 3 comments

Comments

@kilgaloon
Copy link

I don't see a support that we can specify something like X-Header-*. I think this can be useful for some use cases. Maybe it would be good to add support for the wildcard or provide the func similar to the AllowOriginFunc.

@kilgaloon kilgaloon changed the title Wildcard support for AllowedHeaders or AllowedHeadersFunc Wildcard support for AllowedHeaders or add AllowedHeadersFunc Jun 25, 2024
@jub0bs
Copy link
Contributor

jub0bs commented Jun 26, 2024

This seems like an odd use case to me...

  1. How many such request-header names do you typically need to allow in your CORS configuration?
  2. Would allowing all request headers (via AllowedHeaders: "*") not be an acceptable alternative?

Another consideration: security. What if an adversary spoofs a preflight request that contains the following header?

Access-Control-Request-Headers: X-Header-followed_by_a_very_looooooooooooong_character_sequence

Allowing all header names of the form X-Header-* would force the CORS middleware to scan the entire header value, which could be as long as 1 << 20 bytes (and a bit). Such spoofed preflight requests could have a detrimental impact on middleware performance. In this connection, see #170.

@jub0bs
Copy link
Contributor

jub0bs commented Aug 28, 2024

@kilgaloon Any further comment? Can we close this issue?

@jub0bs
Copy link
Contributor

jub0bs commented Aug 31, 2024

@rs Without feedback from the OP, and in light of a recent comment of yours, I'm inclined to reject this suggestion.

@rs rs closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants