-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Allow overriding the host header if doesn't match the absolute-form host #39334
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 |
---|---|---|
|
@@ -36,6 +36,21 @@ public class KestrelServerOptions | |
|
||
private Func<string, Encoding?> _responseHeaderEncodingSelector = DefaultHeaderEncodingSelector; | ||
|
||
private bool? _enableInsecureAbsoluteFormHostOverride; | ||
internal bool EnableInsecureAbsoluteFormHostOverride | ||
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. Is a public version of this the API proposal for .NET 7? 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 we allow for a missing Host header if this is set and there's an absolute form request target? 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. The customer is currently asking for a short term mitigation, it's not clear we'll still need this in 7.0.
We could expand to that if needed, but it hasn't come up yet. So far the client is sending a Host header, but it's malformed. 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. I think it's weird to require a HOST header if we're going to ignore it anyway. What does httpsys do? 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. Http.Sys also always requires the Host header to be present (even if empty), even if it overrides it with the host from the request line. |
||
{ | ||
get | ||
{ | ||
if (!_enableInsecureAbsoluteFormHostOverride.HasValue) | ||
{ | ||
_enableInsecureAbsoluteFormHostOverride = | ||
AppContext.TryGetSwitch("Microsoft.AspNetCore.Server.Kestrel.EnableInsecureAbsoluteFormHostOverride", out var enabled) && enabled; | ||
} | ||
return _enableInsecureAbsoluteFormHostOverride.Value; | ||
} | ||
set => _enableInsecureAbsoluteFormHostOverride = value; | ||
} | ||
|
||
// The following two lists configure the endpoints that Kestrel should listen to. If both lists are empty, the "urls" config setting (e.g. UseUrls) is used. | ||
internal List<ListenOptions> CodeBackedListenOptions { get; } = new List<ListenOptions>(); | ||
internal List<ListenOptions> ConfigurationBackedListenOptions { get; } = new List<ListenOptions>(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.