diff --git a/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs b/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs index 8e49dd054e88..e3f16d85ca59 100644 --- a/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs +++ b/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs @@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Http.Metadata; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.WebUtilities; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Builder; @@ -22,6 +23,21 @@ public static class RoutingEndpointConventionBuilderExtensions /// An empty collection means any host will be accepted. /// /// A reference to this instance after the operation has completed. + /// + /// APIs that depend on the Host header, including + /// and , are vulnerable to client spoofing. + /// + /// To safeguard against host and port spoofing: + /// + /// + /// Verify the server name used during the TLS handshake using ITlsHandshakeFeature.HostName. + /// + /// + /// Verify the local port where the connection was accepted using (specifically ). + /// + /// + /// + /// public static TBuilder RequireHost(this TBuilder builder, params string[] hosts) where TBuilder : IEndpointConventionBuilder { ArgumentNullException.ThrowIfNull(builder);