Skip to content

Commit 8e994a2

Browse files
CopilotMihaZupan
andauthored
Document security risks of fixed multi-byte encodings in HTTP header encoding selectors (#12001)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: MihaZupan <25307628+MihaZupan@users.noreply.github.com>
1 parent ffb55e1 commit 8e994a2

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

xml/System.Net.Http/SocketsHttpHandler.xml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,20 @@ For example, if the value is 64, then 65,536 bytes are allowed for the maximum r
11241124
<Docs>
11251125
<summary>Gets or sets a callback that selects the <see cref="System.Text.Encoding" /> to encode request header values.</summary>
11261126
<value>The header encoding selector callback that selects the <see cref="System.Text.Encoding" /> to encode the value for the specified request header name, or <see langword="null" /> to indicate the default behavior.</value>
1127-
<remarks>To be added.</remarks>
1127+
<remarks>
1128+
<format type="text/markdown"><![CDATA[
1129+
1130+
## Remarks
1131+
1132+
When specifying an encoding, you're generally expected to use one of the following encoding schemes: <xref:System.Text.Encoding.ASCII>, <xref:System.Text.Encoding.Latin1>, or <xref:System.Text.Encoding.UTF8>. Other encoding schemes might be susceptible to request smuggling attacks.
1133+
1134+
> [!CAUTION]
1135+
> Fixed multi-byte encoding schemes in particular (for example, <xref:System.Text.Encoding.Unicode> or <xref:System.Text.Encoding.UTF32>) must never be used, as their binary representation is likely to be misinterpreted and break the protocol. For instance, part of `✊` might be interpreted as a new line (`\n`) that terminates the header value.
1136+
1137+
When you specify an encoding, it's your responsibility to ensure that the values are representable via the encoding, and that the server agrees on the encoding used. Otherwise, values will become corrupted. For example, since any set of bytes is considered a valid Latin1 sequence, a server replying with UTF-8 encoded header values might see its responses silently corrupted.
1138+
1139+
]]></format>
1140+
</remarks>
11281141
<exception cref="T:System.InvalidOperationException">An operation has already been started on the current instance.</exception>
11291142
<exception cref="T:System.ObjectDisposedException">The current instance has been disposed.</exception>
11301143
</Docs>
@@ -1199,7 +1212,20 @@ The timeout specified is greater than <see cref="F:System.Int32.MaxValue" /> mil
11991212
<Docs>
12001213
<summary>Gets or sets a callback that selects the <see cref="System.Text.Encoding" /> to decode response header values.</summary>
12011214
<value>The header encoding selector callback that selects the <see cref="System.Text.Encoding" /> to decode the value for the specified response header name, or <see langword="null" /> to indicate the default behavior.</value>
1202-
<remarks>To be added.</remarks>
1215+
<remarks>
1216+
<format type="text/markdown"><![CDATA[
1217+
1218+
## Remarks
1219+
1220+
When specifying an encoding, you're generally expected to use one of the following encoding schemes: <xref:System.Text.Encoding.ASCII>, <xref:System.Text.Encoding.Latin1>, or <xref:System.Text.Encoding.UTF8>. Other encoding schemes might be susceptible to request smuggling attacks.
1221+
1222+
> [!CAUTION]
1223+
> Fixed multi-byte encoding schemes in particular (for example, <xref:System.Text.Encoding.Unicode> or <xref:System.Text.Encoding.UTF32>) must never be used, as their binary representation is likely to be misinterpreted and break the protocol. For instance, part of `✊` might be interpreted as a new line (`\n`) that terminates the header value.
1224+
1225+
When you specify an encoding, it's your responsibility to ensure that the values are representable via the encoding, and that the server agrees on the encoding used. Otherwise, values will become corrupted. For example, since any set of bytes is considered a valid Latin1 sequence, a server replying with UTF-8 encoded header values might see its responses silently corrupted.
1226+
1227+
]]></format>
1228+
</remarks>
12031229
<exception cref="T:System.InvalidOperationException">An operation has already been started on the current instance.</exception>
12041230
<exception cref="T:System.ObjectDisposedException">The current instance has been disposed.</exception>
12051231
</Docs>

0 commit comments

Comments
 (0)