-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
Background and Motivation
At the request of an internal partner, #39334 introduced an internal API and corresponding appcontext switch that made it possible to overwrite an incorrect Host header with a value derived from an absolute-form request target to handle the surprisingly common client behavior of missing the line-break after the host header, as IIS/Http.Sys did. This PR upgrades it to a public API since those clients aren't going away. The behavior is the same, it just has a name and a doc comment intended for broader consumption.
Proposed API
namespace Microsoft.AspNetCore.Server.Kestrel.Core;
public class KestrelServerOptions
{
+ public bool AllowUnsafeHostHeaderOverride { get; set; }
}
Usage Examples
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseKestrel(serverOptions => {
serverOptions.AllowUnsafeHostHeaderOverride = true
});
Alternative Designs
We could add a new configuration setting, but we don't really want this to be widely used (since it can hide security threats) and the only existing consumer configured it in code.
Risks
Opting in to this setting makes it easier to write a less secure server.