Skip to content

Commit 2d4fd05

Browse files
authored
Add host caution to MVC GetUri extension methods (#12629)
1 parent 98abd9e commit 2d4fd05

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/Mvc/Mvc.Core/src/Routing/ControllerLinkGeneratorExtensions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,14 @@ public static string GetPathByAction(
138138
/// names from <c>RouteOptions</c>.
139139
/// </param>
140140
/// <returns>A absolute URI, or <c>null</c> if a URI cannot be created.</returns>
141+
/// <remarks>
142+
/// <para>
143+
/// The value of <paramref name="host" /> should be a trusted value. Relying on the value of the current request
144+
/// can allow untrusted input to influence the resulting URI unless the <c>Host</c> header has been validated.
145+
/// See the deployment documentation for instructions on how to properly validate the <c>Host</c> header in
146+
/// your deployment environment.
147+
/// </para>
148+
/// </remarks>
141149
public static string GetUriByAction(
142150
this LinkGenerator generator,
143151
HttpContext httpContext,
@@ -189,6 +197,14 @@ public static string GetUriByAction(
189197
/// names from <c>RouteOptions</c>.
190198
/// </param>
191199
/// <returns>A absolute URI, or <c>null</c> if a URI cannot be created.</returns>
200+
/// <remarks>
201+
/// <para>
202+
/// The value of <paramref name="host" /> should be a trusted value. Relying on the value of the current request
203+
/// can allow untrusted input to influence the resulting URI unless the <c>Host</c> header has been validated.
204+
/// See the deployment documentation for instructions on how to properly validate the <c>Host</c> header in
205+
/// your deployment environment.
206+
/// </para>
207+
/// </remarks>
192208
public static string GetUriByAction(
193209
this LinkGenerator generator,
194210
string action,

src/Mvc/Mvc.Core/src/Routing/PageLinkGeneratorExtensions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ public static string GetPathByPage(
135135
/// names from <c>RouteOptions</c>.
136136
/// </param>
137137
/// <returns>A absolute URI, or <c>null</c> if a URI cannot be created.</returns>
138+
/// <remarks>
139+
/// <para>
140+
/// The value of <paramref name="host" /> should be a trusted value. Relying on the value of the current request
141+
/// can allow untrusted input to influence the resulting URI unless the <c>Host</c> header has been validated.
142+
/// See the deployment documentation for instructions on how to properly validate the <c>Host</c> header in
143+
/// your deployment environment.
144+
/// </para>
145+
/// </remarks>
138146
public static string GetUriByPage(
139147
this LinkGenerator generator,
140148
HttpContext httpContext,
@@ -186,6 +194,14 @@ public static string GetUriByPage(
186194
/// names from <c>RouteOptions</c>.
187195
/// </param>
188196
/// <returns>A absolute URI, or <c>null</c> if a URI cannot be created.</returns>
197+
/// <remarks>
198+
/// <para>
199+
/// The value of <paramref name="host" /> should be a trusted value. Relying on the value of the current request
200+
/// can allow untrusted input to influence the resulting URI unless the <c>Host</c> header has been validated.
201+
/// See the deployment documentation for instructions on how to properly validate the <c>Host</c> header in
202+
/// your deployment environment.
203+
/// </para>
204+
/// </remarks>
189205
public static string GetUriByPage(
190206
this LinkGenerator generator,
191207
string page,

0 commit comments

Comments
 (0)