]> Cypherpunks repositories - gostls13.git/commit
net/http: Ensure that CONNECT proxied requests respect MaxResponseHeaderBytes
authorNicholas Husin <husin@google.com>
Mon, 25 Aug 2025 13:07:25 +0000 (13:07 +0000)
committerMarkus Kusano <kusano@google.com>
Wed, 27 Aug 2025 20:40:17 +0000 (13:40 -0700)
commit2ee4b31242e426df757aa09450b744e0af8cb08d
tree2368422ab9e6061f8ea35610f9c1748a9ec0f7f1
parentb21867b1a2a8e276257e3cb81f4a1dc7e8f9e2cd
net/http: Ensure that CONNECT proxied requests respect MaxResponseHeaderBytes

Currently, CONNECT proxied requests use an unlimited Reader. As a
result, a malicious or misbehaving proxy server can send an unlimited
number of bytes to a client; causing the client to indefinitely receive bytes
until it runs out of memory.

To prevent this, we now use a LimitedReader that limits the number of
bytes according to MaxResponseHeaderBytes in Transport. If
MaxResponseHeaderBytes is not provided, we use the default value of 10
MB that has historically been used (see #26315).

Fixes #74633

Change-Id: I0b03bb354139dbc64318874402f7f29cc0fb42ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/698915
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/net/http/transport.go
src/net/http/transport_test.go