]> Cypherpunks repositories - gostls13.git/commit
mime/multipart: limit parsed mime message sizes
authorDamien Neil <dneil@google.com>
Mon, 20 Mar 2023 17:43:19 +0000 (10:43 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 4 Apr 2023 17:02:00 +0000 (17:02 +0000)
commit1e43cfa15b4b618812e85c00c9e92c2615b324c8
tree93dbfdfaaffde711b0c40ea2c8c8c49d0462316f
parent3c010f2c2182a12f28ad86c5e1ff984f1f2d880a
mime/multipart: limit parsed mime message sizes

The parsed forms of MIME headers and multipart forms can consume
substantially more memory than the size of the input data.
A malicious input containing a very large number of headers or
form parts can cause excessively large memory allocations.

Set limits on the size of MIME data:

Reader.NextPart and Reader.NextRawPart limit the the number
of headers in a part to 10000.

Reader.ReadForm limits the total number of headers in all
FileHeaders to 10000.

Both of these limits may be set with with
GODEBUG=multipartmaxheaders=<values>.

Reader.ReadForm limits the number of parts in a form to 1000.
This limit may be set with GODEBUG=multipartmaxparts=<value>.

Thanks for Jakob Ackermann (@das7pad) for reporting this issue.

For CVE-2023-24536
For #59153

Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1802455
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Julie Qiu <julieqiu@google.com>
Change-Id: I08dd297bd75724aade4b0bd6a7d19aeca5bbf99f
Reviewed-on: https://go-review.googlesource.com/c/go/+/482077
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/mime/multipart/formdata.go
src/mime/multipart/formdata_test.go
src/mime/multipart/multipart.go
src/mime/multipart/readmimeheader.go
src/net/textproto/reader.go
src/runtime/metrics.go
src/runtime/metrics/description.go
src/runtime/metrics/doc.go