Skip to content

Add host caution to MVC GetUri extension methods #12629

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

Merged
merged 2 commits into from
Jul 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Mvc/Mvc.Core/src/Routing/ControllerLinkGeneratorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ public static string GetPathByAction(
/// names from <c>RouteOptions</c>.
/// </param>
/// <returns>A absolute URI, or <c>null</c> if a URI cannot be created.</returns>
/// <remarks>
/// <para>
/// The value of <paramref name="host" /> should be a trusted value. Relying on the value of the current request
/// can allow untrusted input to influence the resulting URI unless the <c>Host</c> header has been validated.
/// See the deployment documentation for instructions on how to properly validate the <c>Host</c> header in
/// your deployment environment.
/// </para>
/// </remarks>
public static string GetUriByAction(
this LinkGenerator generator,
HttpContext httpContext,
Expand Down Expand Up @@ -189,6 +197,14 @@ public static string GetUriByAction(
/// names from <c>RouteOptions</c>.
/// </param>
/// <returns>A absolute URI, or <c>null</c> if a URI cannot be created.</returns>
/// <remarks>
/// <para>
/// The value of <paramref name="host" /> should be a trusted value. Relying on the value of the current request
/// can allow untrusted input to influence the resulting URI unless the <c>Host</c> header has been validated.
/// See the deployment documentation for instructions on how to properly validate the <c>Host</c> header in
/// your deployment environment.
/// </para>
/// </remarks>
public static string GetUriByAction(
this LinkGenerator generator,
string action,
Expand Down
16 changes: 16 additions & 0 deletions src/Mvc/Mvc.Core/src/Routing/PageLinkGeneratorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ public static string GetPathByPage(
/// names from <c>RouteOptions</c>.
/// </param>
/// <returns>A absolute URI, or <c>null</c> if a URI cannot be created.</returns>
/// <remarks>
/// <para>
/// The value of <paramref name="host" /> should be a trusted value. Relying on the value of the current request
/// can allow untrusted input to influence the resulting URI unless the <c>Host</c> header has been validated.
/// See the deployment documentation for instructions on how to properly validate the <c>Host</c> header in
/// your deployment environment.
/// </para>
/// </remarks>
public static string GetUriByPage(
this LinkGenerator generator,
HttpContext httpContext,
Expand Down Expand Up @@ -186,6 +194,14 @@ public static string GetUriByPage(
/// names from <c>RouteOptions</c>.
/// </param>
/// <returns>A absolute URI, or <c>null</c> if a URI cannot be created.</returns>
/// <remarks>
/// <para>
/// The value of <paramref name="host" /> should be a trusted value. Relying on the value of the current request
/// can allow untrusted input to influence the resulting URI unless the <c>Host</c> header has been validated.
/// See the deployment documentation for instructions on how to properly validate the <c>Host</c> header in
/// your deployment environment.
/// </para>
/// </remarks>
public static string GetUriByPage(
this LinkGenerator generator,
string page,
Expand Down