-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Have kestrel filter out pseudo headers #36166
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -248,13 +248,14 @@ private bool TryValidatePseudoHeaders() | |
// enabling the use of HTTP to interact with non - HTTP services. | ||
// A common example is TLS termination. | ||
var headerScheme = HttpRequestHeaders.HeaderScheme.ToString(); | ||
HttpRequestHeaders.HeaderScheme = default; // Suppress pseduo headers from the public headers collection. | ||
Tratcher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (!ReferenceEquals(headerScheme, Scheme) && | ||
!string.Equals(headerScheme, Scheme, StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
if (!ServerOptions.AllowAlternateSchemes || !Uri.CheckSchemeName(headerScheme)) | ||
{ | ||
ResetAndAbort(new ConnectionAbortedException( | ||
CoreStrings.FormatHttp2StreamErrorSchemeMismatch(HttpRequestHeaders.HeaderScheme, Scheme)), Http2ErrorCode.PROTOCOL_ERROR); | ||
CoreStrings.FormatHttp2StreamErrorSchemeMismatch(headerScheme, Scheme)), Http2ErrorCode.PROTOCOL_ERROR); | ||
return false; | ||
} | ||
|
||
|
@@ -264,6 +265,7 @@ private bool TryValidatePseudoHeaders() | |
// :path (and query) - Required | ||
// Must start with / except may be * for OPTIONS | ||
var path = HttpRequestHeaders.HeaderPath.ToString(); | ||
HttpRequestHeaders.HeaderPath = default; // Suppress pseduo headers from the public headers collection. | ||
RawTarget = path; | ||
|
||
// OPTIONS - https://tools.ietf.org/html/rfc7540#section-8.1.2.3 | ||
|
@@ -301,6 +303,7 @@ private bool TryValidateMethod() | |
{ | ||
// :method | ||
_methodText = HttpRequestHeaders.HeaderMethod.ToString(); | ||
HttpRequestHeaders.HeaderMethod = default; // Suppress pseduo headers from the public headers collection. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We identified a bug with this approach in 6.0. On line 221 above, TryValidateMethod is skipped if the method was sent via static hpack index. That means we fail to remove it from the collection. #38581 fixed this in inadvertently in 7.0 by bulk clearing the set bits in the collection itself rather than clearing the individual properties. |
||
Method = HttpUtilities.GetKnownMethod(_methodText); | ||
|
||
if (Method == HttpMethod.None) | ||
|
@@ -327,6 +330,7 @@ private bool TryValidateAuthorityAndHost(out string hostText) | |
// Prefer this over Host | ||
|
||
var authority = HttpRequestHeaders.HeaderAuthority; | ||
HttpRequestHeaders.HeaderAuthority = default; // Suppress pseduo headers from the public headers collection. | ||
var host = HttpRequestHeaders.HeaderHost; | ||
if (!StringValues.IsNullOrEmpty(authority)) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -843,7 +843,14 @@ internal partial class {loop.ClassName} : IHeaderDictionary | |
}} | ||
set | ||
{{ | ||
{header.SetBit()}; | ||
if (!StringValues.IsNullOrEmpty(value)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an existing bug in .NET 6 being fixed right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this particular change go into 6.0 RC2? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and yes I plan to backport this entire PR to rc2. |
||
{{ | ||
{header.SetBit()}; | ||
}} | ||
else | ||
{{ | ||
{header.ClearBit()}; | ||
}} | ||
_headers._{header.Identifier} = value; {(header.EnhancedSetter == false ? "" : $@" | ||
_headers._raw{header.Identifier} = null;")} | ||
}}")} | ||
|
Uh oh!
There was an error while loading. Please reload this page.