[go] net/http: raise an error when a http2 header frame is malformed

2 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
9:08 AM (10 hours ago) 9:08 AM
to goph...@pubsubhelper.golang.org, Jonathan Kuma, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

Commit message

net/http: raise an error when a http2 header frame is malformed

This PR attempts to fix : #31986
Change-Id: I9fc01f615de2c3828dd8df0941027ca19a48d299
GitHub-Last-Rev: 2fd7bb149b5eb8f8a2cb7be3f5e9f3e2211a4984
GitHub-Pull-Request: golang/go#76199

Change diff

diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go
index 0df2763..a2b902a 100644
--- a/src/net/http/h2_bundle.go
+++ b/src/net/http/h2_bundle.go
@@ -2044,6 +2044,10 @@
// sends a frame that is larger than declared with SetMaxReadFrameSize.
var http2ErrFrameTooLarge = errors.New("http2: frame too large")

+// ErrFrameHeadersMalformed is returned from Framer.ReadFrame when the
+// peer sends a http2FrameHeaders frame with a malformed header block.
+var http2ErrFrameHeadersMalformed = errors.New("http2: malformed header frame")
+
// terminalReadFrameError reports whether err is an unrecoverable
// error from ReadFrame and no other frames should be read.
func http2terminalReadFrameError(err error) bool {
@@ -2099,7 +2103,12 @@
fr.debugReadLoggerf("http2: Framer %p: read %v", fr, http2summarizeFrame(f))
}
if fh.Type == http2FrameHeaders && fr.ReadMetaHeaders != nil {
- return fr.readMetaFrame(f.(*http2HeadersFrame))
+ hf, ok := f.(*http2HeadersFrame)
+ if !ok {
+ return nil, http2ErrFrameHeadersMalformed
+ }
+
+ return fr.readMetaFrame(hf)
}
return f, nil
}

Change information

Files:
  • M src/net/http/h2_bundle.go
Change size: S
Delta: 1 file changed, 10 insertions(+), 1 deletion(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: I9fc01f615de2c3828dd8df0941027ca19a48d299
Gerrit-Change-Number: 718480
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-CC: Jonathan Kuma <jonath...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
9:08 AM (10 hours ago) 9:08 AM
to Jonathan Kuma, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gopher Robot added 1 comment

Patchset-level comments
File-level comment, Patchset 1 (Latest):
Gopher Robot . unresolved

I spotted some possible problems with your PR:

  1. Are you describing the change in complete sentences with correct punctuation in the commit message body, including ending sentences with periods?
2. Do you have the right bug reference format? For this repo, the format is usually 'Fixes #12345' or 'Updates #12345' at the end of the commit message.

Please address any problems by updating the GitHub PR.

When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above. These findings are based on heuristics; if a finding does not apply, briefly reply here saying so.

To update the commit title or commit message body shown here in Gerrit, you must edit the GitHub PR title and PR description (the first comment) in the GitHub web interface using the 'Edit' button or 'Edit' menu entry there. Note: pushing a new commit to the PR will not automatically update the commit message used by Gerrit.

For more details, see:

(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)

Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I9fc01f615de2c3828dd8df0941027ca19a48d299
    Gerrit-Change-Number: 718480
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Jonathan Kuma <jonath...@gmail.com>
    Gerrit-Comment-Date: Thu, 06 Nov 2025 14:07:57 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gopher Robot (Gerrit)

    unread,
    9:13 AM (10 hours ago) 9:13 AM
    to Jonathan Kuma, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

    Message from Gopher Robot

    Congratulations on opening your first change. Thank you for your contribution!

    Next steps:
    A maintainer will review your change and provide feedback. See
    https://go.dev/doc/contribute#review for more info and tips to get your
    patch through code review.

    Most changes in the Go project go through a few rounds of revision. This can be
    surprising to people new to the project. The careful, iterative review process
    is our way of helping mentor contributors and ensuring that their contributions
    have a lasting impact.

    During May-July and Nov-Jan the Go project is in a code freeze, during which
    little code gets reviewed or merged. If a reviewer responds with a comment like
    R=go1.11 or adds a tag like "wait-release", it means that this CL will be
    reviewed as part of the next development cycle. See https://go.dev/s/release
    for more details.

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I9fc01f615de2c3828dd8df0941027ca19a48d299
    Gerrit-Change-Number: 718480
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Jonathan Kuma <jonath...@gmail.com>
    Gerrit-Comment-Date: Thu, 06 Nov 2025 14:13:07 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gerrit Bot (Gerrit)

    unread,
    11:46 AM (8 hours ago) 11:46 AM
    to Jonathan Kuma, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
    Attention needed from Damien Neil

    Gerrit Bot uploaded new patchset

    Gerrit Bot uploaded patch set #2 to this change.
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: newpatchset
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I9fc01f615de2c3828dd8df0941027ca19a48d299
    Gerrit-Change-Number: 718480
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Jonathan Kuma <jonath...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-Attention: Damien Neil <dn...@google.com>
    unsatisfied_requirement
    open
    diffy

    Damien Neil (Gerrit)

    unread,
    6:55 PM (26 minutes ago) 6:55 PM
    to Jonathan Kuma, Gerrit Bot, goph...@pubsubhelper.golang.org, Russ Cox, Gopher Robot, golang-co...@googlegroups.com

    Damien Neil added 1 comment

    File src/net/http/h2_bundle.go
    Line 2109, Patchset 2 (Latest): }
    Damien Neil . unresolved

    I commented on https://go.dev/issue/31986 in more detail, but:

    I don't see any way that this type assertion cannot succeed without some form of memory corruption happening. If the frame type is FrameHeaders, then the frame parser can only return a *HeadersFrame.

    Open in Gerrit

    Related details

    Attention set is empty
    Submit Requirements:
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement is not satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: I9fc01f615de2c3828dd8df0941027ca19a48d299
    Gerrit-Change-Number: 718480
    Gerrit-PatchSet: 2
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-Reviewer: Damien Neil <dn...@google.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Jonathan Kuma <jonath...@gmail.com>
    Gerrit-CC: Russ Cox <r...@golang.org>
    Gerrit-Comment-Date: Thu, 06 Nov 2025 23:55:01 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy
    Reply all
    Reply to author
    Forward
    0 new messages