Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/binary: ReadUvarint and ReadVarint can read an unlimited number of bytes from invalid inputs #40618

Closed
katiehockman opened this issue Aug 6, 2020 · 1 comment
Assignees
Labels
Milestone

Comments

@katiehockman
Copy link
Member

@katiehockman katiehockman commented Aug 6, 2020

Certain invalid inputs to ReadUvarint or ReadVarint could cause those functions to read an unlimited number of bytes from the ByteReader argument before returning an error. This could lead to processing more input than expected when the caller is reading directly from the network and depends on ReadUvarint and ReadVarint only consuming a small, bounded number of bytes, even from invalid inputs.

With the update, ReadUvarint and ReadVarint now always return after consuming a bounded number of bytes (specifically, MaxVarintLen64, which is 10). The result being returned has not changed; the functions merely detect and return some errors without reading as much input.

Thanks to Diederik Loerakker, Jonny Rhea, Raúl Kripalani, and Preston Van Loon for reporting this issue.

This issue is CVE-2020-16845.

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 6, 2020

Change https://golang.org/cl/247120 mentions this issue: encoding/binary: read at most MaxVarintLen64 bytes in ReadUvarint

gopherbot pushed a commit that referenced this issue Aug 6, 2020
This CL ensures that ReadUvarint consumes only a limited
amount of input (instead of an unbounded amount).

On some inputs, ReadUvarint could read an arbitrary number
of bytes before deciding to return an overflow error.
After this CL, ReadUvarint returns that same overflow
error sooner, after reading at most MaxVarintLen64 bytes.

Fix authored by Robert Griesemer and Filippo Valsorda.

Thanks to Diederik Loerakker, Jonny Rhea, Raúl Kripalani,
and Preston Van Loon for reporting this.

Fixes #40618
Fixes CVE-2020-16845

Change-Id: Ie0cb15972f14c38b7cf7af84c45c4ce54909bb8f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/812099
Reviewed-by: Filippo Valsorda <valsorda@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/247120
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
alessio added a commit to cosmos/cosmos-sdk that referenced this issue Oct 15, 2020
Update tendermint to 0.33.8, see [1] for more information.

[1] golang/go#40618
@alessio alessio mentioned this issue Oct 15, 2020
0 of 9 tasks complete
alessio added a commit to cosmos/cosmos-sdk that referenced this issue Oct 15, 2020
Update tendermint to 0.33.8, see [1] for more information.

[1] golang/go#40618
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.