Skip to content

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

Closed

Description

@katiehockman

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.

Activity

  1. added this to the Go1.15 milestone on Aug 6, 2020
  2. self-assigned this
    on Aug 6, 2020
  3. gopherbot commented on Aug 6, 2020

    @gopherbot
    Contributor

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

  4. added a commit that references this issue on Aug 6, 2020
    027d724
  5. locked and limited conversation to collaborators on Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions