go/src
Damien Neil ec8c526e4b [release-branch.go1.21] net/http: limit chunked data overhead
The chunked transfer encoding adds some overhead to
the content transferred. When writing one byte per
chunk, for example, there are five bytes of overhead
per byte of data transferred: "1\r\nX\r\n" to send "X".

Chunks may include "chunk extensions",
which we skip over and do not use.
For example: "1;chunk extension here\r\nX\r\n".

A malicious sender can use chunk extensions to add
about 4k of overhead per byte of data.
(The maximum chunk header line size we will accept.)

Track the amount of overhead read in chunked data,
and produce an error if it seems excessive.

Updates #64433
Fixes #64435
Fixes CVE-2023-39326

Change-Id: I40f8d70eb6f9575fb43f506eb19132ccedafcf39
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2076135
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
(cherry picked from commit 3473ae72ee66c60744665a24b2fde143e8964d4f)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2095408
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/547356
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-12-05 17:18:23 +00:00
..
archive
arena
bufio
builtin
bytes bytes: remove builders check from compare test 2023-07-13 23:11:42 +00:00
cmd [release-branch.go1.21] cmd/compile: fix findIndVar so it does not match disjointed loop headers 2023-11-28 20:12:59 +00:00
cmp
compress compress/bzip2: fix typo 2023-06-16 18:24:46 +00:00
container
context [release-branch.go1.21] context: fix synchronization in ExampleAfterFunc_cond 2023-08-24 21:13:14 +00:00
crypto [release-branch.go1.21] crypto/rand,runtime: switch RtlGenRandom for ProcessPrng 2023-11-28 17:48:47 +00:00
database/sql src/database/sql: run gofmt 2023-07-07 20:48:55 +00:00
debug
embed
encoding [release-branch.go1.21] encoding/xml: overriding by empty namespace when no new name declaration 2023-08-30 20:17:11 +00:00
errors
expvar
flag
fmt
go [release-branch.go1.21] path/filepath: fix various issues in parsing Windows paths 2023-11-07 16:36:54 +00:00
hash
html [release-branch.go1.21] html/template: properly handle special tags within the script context 2023-09-06 14:20:20 +00:00
image
index/suffixarray
internal [release-branch.go1.21] crypto/rand,runtime: switch RtlGenRandom for ProcessPrng 2023-11-28 17:48:47 +00:00
io
log [release-branch.go1.21] log/slog: fix comment above log levels 2023-07-24 17:02:06 +00:00
maps [release-branch.go1.21] maps: remove Keys and Values 2023-07-27 22:20:27 +00:00
math math: test large negative values as args for trig functions 2023-07-17 21:05:34 +00:00
mime
net [release-branch.go1.21] net/http: limit chunked data overhead 2023-12-05 17:18:23 +00:00
os [release-branch.go1.21] os: report IO_REPARSE_TAG_DEDUP files as regular in Stat and Lstat 2023-11-08 18:13:06 +00:00
path [release-branch.go1.21] path/filepath: consider \\?\c: as a volume on Windows 2023-11-28 16:59:27 +00:00
plugin
reflect reflect: fix ArenaNew to match documentation 2023-06-16 17:08:43 +00:00
regexp
runtime [release-branch.go1.21] runtime: call enableMetadataHugePages and its callees on the systemstack 2023-11-28 18:46:34 +00:00
slices slices, maps: add examples; doc comment fixes 2023-06-29 15:34:32 +00:00
sort
strconv
strings
sync
syscall [release-branch.go1.21] syscall: copy rlimit.go's build constraint to rlimit_test.go 2023-11-07 20:32:49 +00:00
testdata
testing testing/slogtest: check for no group with empty record 2023-07-11 20:08:28 +00:00
text text/template: set variables correctly in range assignment 2023-06-15 14:28:01 +00:00
time time: increase arbitrary upper bound in TestReset to 10s 2023-07-11 13:19:40 +00:00
unicode
unsafe
vendor [release-branch.go1.21] net/http: pull http2 underflow fix from x/net/http2 2023-10-30 21:11:25 +00:00
Make.dist
README.vendor src/README.vendor: s/latest/master/ 2023-07-11 21:30:51 +00:00
all.bash
all.bat
all.rc
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash
go.mod [release-branch.go1.21] net/http: pull http2 underflow fix from x/net/http2 2023-10-30 21:11:25 +00:00
go.sum [release-branch.go1.21] net/http: pull http2 underflow fix from x/net/http2 2023-10-30 21:11:25 +00:00
make.bash
make.bat
make.rc
race.bash
race.bat
run.bash
run.bat
run.rc

README.vendor

Vendoring in std and cmd
========================

The Go command maintains copies of external packages needed by the
standard library in the src/vendor and src/cmd/vendor directories.

There are two modules, std and cmd, defined in src/go.mod and
src/cmd/go.mod. When a package outside std or cmd is imported
by a package inside std or cmd, the import path is interpreted
as if it had a "vendor/" prefix. For example, within "crypto/tls",
an import of "golang.org/x/crypto/cryptobyte" resolves to
"vendor/golang.org/x/crypto/cryptobyte". When a package with the
same path is imported from a package outside std or cmd, it will
be resolved normally. Consequently, a binary may be built with two
copies of a package at different versions if the package is
imported normally and vendored by the standard library.

Vendored packages are internally renamed with a "vendor/" prefix
to preserve the invariant that all packages have distinct paths.
This is necessary to avoid compiler and linker conflicts. Adding
a "vendor/" prefix also maintains the invariant that standard
library packages begin with a dotless path element.

The module requirements of std and cmd do not influence version
selection in other modules. They are only considered when running
module commands like 'go get' and 'go mod vendor' from a directory
in GOROOT/src.

Maintaining vendor directories
==============================

Before updating vendor directories, ensure that module mode is enabled.
Make sure that GO111MODULE is not set in the environment, or that it is
set to 'on' or 'auto'.

Requirements may be added, updated, and removed with 'go get'.
The vendor directory may be updated with 'go mod vendor'.
A typical sequence might be:

    cd src
    go get golang.org/x/net@master
    go mod tidy
    go mod vendor

Use caution when passing '-u' to 'go get'. The '-u' flag updates
modules providing all transitively imported packages, not only
the module providing the target package.

Note that 'go mod vendor' only copies packages that are transitively
imported by packages in the current module. If a new package is needed,
it should be imported before running 'go mod vendor'.