Skip to content

net/http: backport fix to protect against middleware changing server response body [1.26 backport] #81946

Open

Description

@neild

The Handler documentation states that handlers should not modify their request: "Except for reading the body, handlers should not modify the provided Request."

CL 794640 added some hardening to the server to defend against handlers improperly changing Request.Body. While this doesn't affect well-behaved handlers, it is not unknown for programs in the wild to replace the request body without creating a new request. (See the implementation of MaxBytesHandler for the correct way to do this.)

We should backport the fix to 1.26 as a general hardening measure.

Activity

  1. added this to the Go1.26.9 milestone on Oct 1, 2026
  2. gopherbot commented on Oct 1, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/843365 mentions this issue: [release-branch.go1.26] net/http: don't rely on server request body not changing

  3. gopherbot commented on Oct 2, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/843566 mentions this issue: [release-branch.go1.26] net/http: clear io.EOF when Close drains a server request body

  4. modified the milestones: Go1.26.9, Go1.26.10 on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CherryPickCandidateUsed during the release process for point releases

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions