Skip to content

Commit d13431c

Browse files
neildmknyszek
authored andcommitted
[release-branch.go1.17] net/http: don't strip whitespace from Transfer-Encoding headers
Do not accept "Transfer-Encoding: \rchunked" as a valid TE header setting chunked encoding. Thanks to Zeyu Zhang (https://www.zeyu2001.com/) for identifying the issue. For #53188 For CVE-2022-1705 Fixes #53432 Change-Id: I1a16631425159267f2eca68056b057192a7edf6c Reviewed-on: https://go-review.googlesource.com/c/go/+/409874 Reviewed-by: Roland Shoemaker <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]> (cherry picked from commit e5017a9) Reviewed-on: https://go-review.googlesource.com/c/go/+/415217 Reviewed-by: Dmitri Shuralyov <[email protected]> Run-TryBot: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent ae2dfcc commit d13431c

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/net/http/serve_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6189,6 +6189,7 @@ func TestUnsupportedTransferEncodingsReturn501(t *testing.T) {
61896189
"fugazi",
61906190
"foo-bar",
61916191
"unknown",
6192+
"\rchunked",
61926193
}
61936194

61946195
for _, badTE := range unsupportedTEs {

src/net/http/transfer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ func (t *transferReader) parseTransferEncoding() error {
639639
if len(raw) != 1 {
640640
return &unsupportedTEError{fmt.Sprintf("too many transfer encodings: %q", raw)}
641641
}
642-
if !ascii.EqualFold(textproto.TrimString(raw[0]), "chunked") {
642+
if !ascii.EqualFold(raw[0], "chunked") {
643643
return &unsupportedTEError{fmt.Sprintf("unsupported transfer encoding: %q", raw[0])}
644644
}
645645

0 commit comments

Comments
 (0)