-
Notifications
You must be signed in to change notification settings - Fork 524
Configure header parsing to allow non-compliant headers #1144
Comments
In practice I expect this to become an FAQ where most people turn on UTF-8, so we should consider making that the default. Have we tested how these headers forward through IIS? WebListener? |
I like how we say "We" Nope, please try it :p |
@halter73 please work with @CesarBS, based on timing this may be load balanced to you. cc @davidfowl |
A big change (essentially a rewrite in header processing) so moving to 1.2.0. @Tratcher could you file a corresponding bug on WebListener repo? |
Should also fix: #1125 |
Investigating this. Will check how those headers forward through IIS, and also what other servers do. |
Here's what I found so far:
A relevant bit from the RFC:
I think the most relevant part here is:
So it's not forbidding chars above 0x7F.
The most correct behavior seems to be to accept characters in the 0x80 - 0xFF range (which we reject at present), but to let the app decide the encoding. Http.sys appears to deviate from this though, by decoding as UTF-8. |
For reference, which header did you test? You may get different results for a common header vs a custom header. E.g. Host and Location are often special cased. |
How does Apache leave it up to the app to decode it? Does it expose the raw header bytes? |
I was hoping we could address response headers separately. Although related, apps have more control over the response headers whereas they cannot control what request headers are sent by clients.
|
We ran into this issue as well. |
Parsing of request headers with UTF-8 encoded values has been merged and will be available in 2.2.0-preview2. |
I've continued to do some additional investigation in how servers handle header names, path and query strings with non-ascii characters and this is what I found:
Header names with non-ascii characters are almost universally rejected, other than nginx. We should follow the same pattern and continue to reject these requests. There's less consensus in how to treat requests with non-ascii characters in path and query string but these should be URL encoded. I think we can continue to reject these requests too, unless we have a compelling reason to do otherwise. |
I think it's highly critical to address this issue., at least in term of "removing" non-ascii headers. |
@effyteva I have already made the changes to accept UTF-8 encoded characters in header values, which means UTF-8 encoded urls in the |
@JunTaoLuo sorry, I didn't understand you already committed those changes for the 2.2 release. |
We decided to not pursue accepting non-ASCII characters in header names, path and query string at this time. If there is compelling reason to enable these scenarios, please file another issue and we will re-prioritize. A follow up issue to address UTF-8 values in response header values has been filed at https://github.com/aspnet/KestrelHttpServer/issues/2884. |
Thanks for this fix. Is there an ETA for 2.2.0 release? @JunTaoLuo |
See the roadmap. |
We can encode. It is okay but what if we are migrating an old application to aspnetcore that already have too many customers who has the cookie contains non-ascii characters? For now, there is a workaround if you are using nginx at the front of your aspnetcore application. To remove all of the non ascii characters from the request header:
|
We still suffer from the issue, after upgrading to ASP.NET Core 2.2. |
Comments on closed issues are not tracked, please open a new issue with the details for your scenario. |
Rather than rejecting requests, allow configuration to either ignore UTF8 headers, or, parse them, even if they're illegal.
I suggest an enum Reject, Ignore, Parse.
However on output we should still be strict, UrlEncoding cookie values etc.
See #1076 and #1125
edit by @muratg: We should also consider request line when we get to this. #2647
The text was updated successfully, but these errors were encountered: