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

x/net/dns/dnsmessage: does not support RFC 2673 bit-string labels #52489

Open
chushuai opened this issue Apr 22, 2022 · 1 comment
Open

x/net/dns/dnsmessage: does not support RFC 2673 bit-string labels #52489

chushuai opened this issue Apr 22, 2022 · 1 comment
Labels
help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@chushuai
Copy link

chushuai commented Apr 22, 2022

What version of Go are you using (go version)?

$ go version  
go version go1.18.1 linux/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2993232734=/tmp/go-build -gno-record-gcc-switches"

What did you do?

`
Here is TCP DNS payload
hexStream := "00600006850000010001000100000776657273696f6e0462696e640000100003c00c0010000300000000002827392e382e327263312d5265644861742d392e382e322d302e36382e7263312e656c365f31302e38c00c00020003000000000002c00c"

data, _ := hex.DecodeString(hexStream)`

https://github.com/golang/net/blob/1d1ef9303861d099ec7e69ccb17377e0c443542d/dns/dnsmessage/message.go#L2041

  • wireshark code here

     case 0x40:
     //Extended label (RFC 2673) 
     switch (component_len & 0x3f) {
    
       case 0x01:
         /* Bitstring label */
       {
         int bit_count;
         int label_len;
         int print_len;
    
         bit_count = tvb_get_guint8(tvb, offset);
         offset++;
         label_len = (bit_count - 1) / 8 + 1;
    
         if (maxname > 0) {
           print_len = g_snprintf(np, maxname, "\\[x");
           if (print_len <= maxname) {
             np      += print_len;
             maxname -= print_len;
           } else {
             /* Nothing printed, as there's no room.
                Suppress all subsequent printing. */
             maxname = 0;
           }
         }
         while (label_len--) {
           if (maxname > 0) {
             print_len = g_snprintf(np, maxname, "%02x",
                                    tvb_get_guint8(tvb, offset));
             if (print_len <= maxname) {
               np      += print_len;
               maxname -= print_len;
             } else {
               /* Nothing printed, as there's no room.
                  Suppress all subsequent printing. */
               maxname = 0;
             }
           }
           offset++;
         }
         if (maxname > 0) {
           print_len = g_snprintf(np, maxname, "/%d]", bit_count);
           if (print_len <= maxname) {
             np      += print_len;
             maxname -= print_len;
           } else {
             /* Nothing printed, as there's no room.
                Suppress all subsequent printing. */
             maxname = 0;
           }
         }
       }
       break;
    
       default:
         *name="<Unknown extended label>";
         *name_len = (guint)strlen(*name);
         /* Parsing will probably fail from here on, since the */
         /* label length is unknown... */
         len = offset - start_offset;
         if (len < min_len) {
           THROW(ReportedBoundsError);
         }
         return len;
     }
     break;`
    

What did you expect to see?

image

What did you see instead?

@ianlancetaylor ianlancetaylor changed the title Dnsmessage not Support ! qname '0x40' affected/package: dns/dnsmessage/message x/net/dns/dnsmessage: does not support RFC 2673 bit-string labels Apr 22, 2022
@gopherbot gopherbot added this to the Unreleased milestone Apr 22, 2022
@ianlancetaylor ianlancetaylor added help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 22, 2022
@mateusz834
Copy link
Member

mateusz834 commented Nov 7, 2023

As a note the Bit-String Labels are deprecated by RFC 6891.

[RFC2671] specified extended label types. The only such label
proposed was in [RFC2673] for a label type called "Bit-String Label"
or "Binary Labels", with this latest term being the one in common
use. For various reasons, introducing a new label type was found to
be extremely difficult, and [RFC2673] was moved to Experimental.
This document obsoletes [RFC2673], deprecating Binary Labels.
Extended labels remain defined, but their use is discouraged due to
practical difficulties with deployment; their use in the future
SHOULD only be considered after careful evaluation of the deployment
hindrances.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants