[net] dns/dnsmessage: add boundary check in unpackSVCBResource

5 views
Skip to first unread message

Gerrit Bot (Gerrit)

unread,
May 22, 2026, 10:26:10 AMMay 22
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Gerrit Bot has uploaded the change for review

Commit message

dns/dnsmessage: add boundary check in unpackSVCBResource

Currently, bodyEnd is calculated using the length parameter from the resource header without verifying if it exceeds the physical capacity of the msg buffer. If a malformed record provides a length that exceeds the buffer, it bypasses the first-pass parameter validation and causes an out-of-bounds slice during the second-pass copy operation.

Adding a check against len(msg) aligns this function with the boundary enforcement used throughout the rest of the package.
Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
GitHub-Last-Rev: 8e4d7a53fd6cdc5ef7d303660d56321015df7022
GitHub-Pull-Request: golang/net#249

Change diff

diff --git a/dns/dnsmessage/svcb.go b/dns/dnsmessage/svcb.go
index 4840516..3eef598 100644
--- a/dns/dnsmessage/svcb.go
+++ b/dns/dnsmessage/svcb.go
@@ -189,6 +189,10 @@
paramsOff := off
bodyEnd := off + int(length)

+ if bodyEnd > len(msg) {
+ return SVCBResource{}, errResourceLen
+ }
+
var err error
if r.Priority, paramsOff, err = unpackUint16(msg, paramsOff); err != nil {
return SVCBResource{}, &nestedError{"Priority", err}

Change information

Files:
  • M dns/dnsmessage/svcb.go
Change size: XS
Delta: 1 file changed, 4 insertions(+), 0 deletions(-)
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: net
Gerrit-Branch: master
Gerrit-Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
Gerrit-Change-Number: 781880
Gerrit-PatchSet: 1
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Gopher Robot (Gerrit)

unread,
May 22, 2026, 10:26:13 AMMay 22
to 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. You have a long 343 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)
2. You usually need to reference a bug number for all but trivial or cosmetic fixes. For the net repo, the format is usually 'Fixes golang/go#12345' or 'Updates golang/go#12345' at the end of the commit message. Should you have a bug reference?

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: net
    Gerrit-Branch: master
    Gerrit-Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
    Gerrit-Change-Number: 781880
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Fri, 22 May 2026 14:26:09 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    Gopher Robot (Gerrit)

    unread,
    May 22, 2026, 10:30:15 AMMay 22
    to 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: net
    Gerrit-Branch: master
    Gerrit-Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
    Gerrit-Change-Number: 781880
    Gerrit-PatchSet: 1
    Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-Comment-Date: Fri, 22 May 2026 14:30:10 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: No
    unsatisfied_requirement
    open
    diffy

    ISMAIL GAMAL (Gerrit)

    unread,
    May 24, 2026, 3:54:30 PMMay 24
    to Gerrit Bot, goph...@pubsubhelper.golang.org, Damien Neil, Ian Lance Taylor, Nicholas Husin, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Damien Neil, Ian Lance Taylor and Nicholas Husin

    ISMAIL GAMAL added 1 comment

    Patchset-level comments
    Gopher Robot . resolved

    I spotted some possible problems with your PR:

      1. You have a long 343 character line in the commit message body. Please add line breaks to long lines that should be wrapped. Lines in the commit message body should be wrapped at ~76 characters unless needed for things like URLs or tables. (Note: GitHub might render long lines as soft-wrapped, so double-check in the Gerrit commit message shown above.)
    2. You usually need to reference a bug number for all but trivial or cosmetic fixes. For the net repo, the format is usually 'Fixes golang/go#12345' or 'Updates golang/go#12345' at the end of the commit message. Should you have a bug reference?

    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.)

    ISMAIL GAMAL

    Done. Wrapped line lengths. There is no linked bug number in order to avoid publicly disclosing the crash vectors prior to the patch.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Damien Neil
    • Ian Lance Taylor
    • Nicholas Husin
    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: comment
      Gerrit-Project: net
      Gerrit-Branch: master
      Gerrit-Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
      Gerrit-Change-Number: 781880
      Gerrit-PatchSet: 1
      Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
      Gerrit-Reviewer: Damien Neil <dn...@google.com>
      Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Reviewer: Nicholas Husin <n...@golang.org>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: ISMAIL GAMAL <ismailism...@gmail.com>
      Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
      Gerrit-Attention: Damien Neil <dn...@google.com>
      Gerrit-Attention: Nicholas Husin <n...@golang.org>
      Gerrit-Comment-Date: Sun, 24 May 2026 19:54:24 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: No
      Comment-In-Reply-To: Gopher Robot <go...@golang.org>
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Gerrit Bot (Gerrit)

      unread,
      May 24, 2026, 3:56:00 PMMay 24
      to ISMAIL GAMAL, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
      Attention needed from Damien Neil, Ian Lance Taylor and Nicholas Husin

      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
      • Ian Lance Taylor
      • Nicholas Husin
      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: newpatchset
      Gerrit-Project: net
      Gerrit-Branch: master
      Gerrit-Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
      Gerrit-Change-Number: 781880
      Gerrit-PatchSet: 2
      unsatisfied_requirement
      satisfied_requirement
      open
      diffy

      Sean Liao (Gerrit)

      unread,
      May 25, 2026, 7:00:05 AMMay 25
      to ISMAIL GAMAL, Gerrit Bot, goph...@pubsubhelper.golang.org, Damien Neil, Ian Lance Taylor, Nicholas Husin, Gopher Robot, golang-co...@googlegroups.com
      Attention needed from Damien Neil, Ian Lance Taylor and Nicholas Husin

      Sean Liao added 1 comment

      Patchset-level comments
      File-level comment, Patchset 2 (Latest):
      Sean Liao . unresolved

      is this something that can easily be tested?

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Damien Neil
      • Ian Lance Taylor
      • Nicholas Husin
      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: net
        Gerrit-Branch: master
        Gerrit-Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
        Gerrit-Change-Number: 781880
        Gerrit-PatchSet: 2
        Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
        Gerrit-Reviewer: Damien Neil <dn...@google.com>
        Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
        Gerrit-Reviewer: Nicholas Husin <n...@golang.org>
        Gerrit-CC: Gopher Robot <go...@golang.org>
        Gerrit-CC: ISMAIL GAMAL <ismailism...@gmail.com>
        Gerrit-CC: Sean Liao <se...@liao.dev>
        Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
        Gerrit-Attention: Damien Neil <dn...@google.com>
        Gerrit-Attention: Nicholas Husin <n...@golang.org>
        Gerrit-Comment-Date: Mon, 25 May 2026 10:59:59 +0000
        Gerrit-HasComments: Yes
        Gerrit-Has-Labels: No
        unsatisfied_requirement
        open
        diffy

        ISMAIL GAMAL (Gerrit)

        unread,
        May 25, 2026, 12:01:10 PMMay 25
        to Gerrit Bot, goph...@pubsubhelper.golang.org, Damien Neil, Ian Lance Taylor, Nicholas Husin, Gopher Robot, golang-co...@googlegroups.com
        Attention needed from Damien Neil, Ian Lance Taylor, Nicholas Husin and Sean Liao

        ISMAIL GAMAL added 1 comment

        Patchset-level comments
        Sean Liao . resolved

        is this something that can easily be tested?

        ISMAIL GAMAL

        Yes, I have just amended the commit to include TestSVCBUnpackOutOfBounds in svcb_test.go.

        The test feeds a minimal DNS packet with a maliciously large Length header into Message.Unpack(). Without the fix, this triggers the out-of-bounds slice panic during the second pass. With the fix, it safely returns a parsing error.

        Open in Gerrit

        Related details

        Attention is currently required from:
        • Damien Neil
        • Ian Lance Taylor
        • Nicholas Husin
        • Sean Liao
        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: comment
          Gerrit-Project: net
          Gerrit-Branch: master
          Gerrit-Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
          Gerrit-Change-Number: 781880
          Gerrit-PatchSet: 2
          Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
          Gerrit-Reviewer: Damien Neil <dn...@google.com>
          Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
          Gerrit-Reviewer: Nicholas Husin <n...@golang.org>
          Gerrit-CC: Gopher Robot <go...@golang.org>
          Gerrit-CC: ISMAIL GAMAL <ismailism...@gmail.com>
          Gerrit-CC: Sean Liao <se...@liao.dev>
          Gerrit-Attention: Sean Liao <se...@liao.dev>
          Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
          Gerrit-Attention: Damien Neil <dn...@google.com>
          Gerrit-Attention: Nicholas Husin <n...@golang.org>
          Gerrit-Comment-Date: Mon, 25 May 2026 16:01:02 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          Comment-In-Reply-To: Sean Liao <se...@liao.dev>
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          Gerrit Bot (Gerrit)

          unread,
          May 25, 2026, 12:03:07 PMMay 25
          to ISMAIL GAMAL, goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com
          Attention needed from Damien Neil, Ian Lance Taylor, Nicholas Husin and Sean Liao

          Gerrit Bot uploaded new patchset

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

          Related details

          Attention is currently required from:
          • Damien Neil
          • Ian Lance Taylor
          • Nicholas Husin
          • Sean Liao
          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: newpatchset
          Gerrit-Project: net
          Gerrit-Branch: master
          Gerrit-Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
          Gerrit-Change-Number: 781880
          Gerrit-PatchSet: 3
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy

          ISMAIL GAMAL (Gerrit)

          unread,
          Jun 26, 2026, 6:09:21 PM (13 hours ago) Jun 26
          to Gerrit Bot, goph...@pubsubhelper.golang.org, Damien Neil, Ian Lance Taylor, Nicholas Husin, Gopher Robot, golang-co...@googlegroups.com
          Attention needed from Damien Neil, Ian Lance Taylor, Nicholas Husin and Sean Liao

          ISMAIL GAMAL added 1 comment

          Patchset-level comments
          File-level comment, Patchset 3 (Latest):
          ISMAIL GAMAL . resolved

          Hi @dn...@google.com @se...@liao.dev @ia...@golang.org,

          Just a friendly ping on this CL. I added the requested test case in the latest patchset to verify the boundary check.

          Could someone please trigger the TryBots for this when you have a moment? Let me know if there is anything else needed from my end to get this ready for merge.

          Open in Gerrit

          Related details

          Attention is currently required from:
          • Damien Neil
          • Ian Lance Taylor
          • Nicholas Husin
          • Sean Liao
          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: comment
          Gerrit-Project: net
          Gerrit-Branch: master
          Gerrit-Change-Id: I13f6ca83d1c30eac02286a49c12f8ec543d33e41
          Gerrit-Change-Number: 781880
          Gerrit-PatchSet: 3
          Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
          Gerrit-Reviewer: Damien Neil <dn...@google.com>
          Gerrit-Reviewer: Ian Lance Taylor <ia...@golang.org>
          Gerrit-Reviewer: Nicholas Husin <n...@golang.org>
          Gerrit-CC: Gopher Robot <go...@golang.org>
          Gerrit-CC: ISMAIL GAMAL <ismailism...@gmail.com>
          Gerrit-CC: Sean Liao <se...@liao.dev>
          Gerrit-Attention: Sean Liao <se...@liao.dev>
          Gerrit-Attention: Ian Lance Taylor <ia...@golang.org>
          Gerrit-Attention: Damien Neil <dn...@google.com>
          Gerrit-Attention: Nicholas Husin <n...@golang.org>
          Gerrit-Comment-Date: Fri, 26 Jun 2026 22:09:12 +0000
          Gerrit-HasComments: Yes
          Gerrit-Has-Labels: No
          unsatisfied_requirement
          satisfied_requirement
          open
          diffy
          Reply all
          Reply to author
          Forward
          0 new messages