diff --git a/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs b/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs index fbb25d95130f..3820785250ab 100644 --- a/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs +++ b/src/Http/Routing/src/Builder/RoutingEndpointConventionBuilderExtensions.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Metadata; using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.WebUtilities; @@ -22,6 +23,20 @@ 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);