ssh: drain stderr on forwarded TCP and Unix channels tcpListener.Accept, unixListener.Accept, Client.dial and Client.dialStreamLocal only read the main stream of the channels they return. Data sent by the peer on the extended (stderr) stream accumulates in the extPending buffer and its window credit is only returned by ReadExtended, which is never called. Since the window is shared between the two streams, a misbehaving peer can pin up to 2 MiB per channel and eventually stall it; well-behaved peers never send stderr on these channel types. Drain the stderr stream into io.Discard, mirroring CL 783720 which fixed the same issue in the agent forwarders. The drain takes precedence over reading Stderr through a type assertion on the returned net.Conn, which was never a supported use. For comparison, OpenSSH refuses extended data on these channel types and drops the payload without buffering it. Updates golang/go#80333 Change-Id: I4f1445eee9ce1b56ca62cec342812d63cfdd3e13 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/802900 Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This repository holds supplementary Go cryptography packages.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.
The git repository is https://go.googlesource.com/crypto.
The main issue tracker for the crypto repository is located at https://go.dev/issues. Prefix your issue with “x/crypto:” in the subject line, so it is easy to find.
Note that contributions to the cryptography package receive additional scrutiny due to their sensitive nature. Patches may take longer than normal to receive feedback.