Skip to content

Commit 222ee24

Browse files
neildmknyszek
authored andcommitted
[release-branch.go1.18] 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 #53433 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/+/415218 Reviewed-by: Dmitri Shuralyov <[email protected]> Run-TryBot: Dmitri Shuralyov <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]>
1 parent 93aab18 commit 222ee24

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
@@ -6250,6 +6250,7 @@ func TestUnsupportedTransferEncodingsReturn501(t *testing.T) {
62506250
"fugazi",
62516251
"foo-bar",
62526252
"unknown",
6253+
"\rchunked",
62536254
}
62546255

62556256
for _, badTE := range unsupportedTEs {

src/net/http/transfer.go

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

0 commit comments

Comments
 (0)