-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
net: isDomainName rejects valid domains #17659
Comments
/cc @rsc in case he disagrees |
The hard part here is that it seems to be the case that not any binary name should be accepted. Otherwise thing like Punycode would not exist. What is the dividing line for what can be looked up directly and what needs special processing? |
Not according to RFC1035. However, RFC 2181 updates RFC1035 in the way @gibson042 reported, ie. a label can consist of any octets. RFC4343, Section 2 discusses handling and escaping non-ASCII labels. |
https://tools.ietf.org/html/rfc6055#section-3 shows some discussion on the use of non-LDH labels in DNS. |
Thanks for the links, but looks like there's still no decision here. Bumping to Go 1.10. /cc @mdempsky |
Change https://golang.org/cl/73830 mentions this issue: |
I finally got around to fixing this—the code should clarify any open questions, but I'm also happy to address them directly. |
It looks like we are still waiting on a proposed answer for the question above: "What is the dividing line for what can be looked up directly and what needs special processing?" Can anyone give an authoritative answer or at least make a good suggestion? |
I don't really understand the naming rules well enough to provide a specific answer, but my general opinion is that the DNS client library should err on the side of being permissive, unless there's a compelling reason not to. |
I don't have an answer to the question about what needs special processing, but I wanted to offer support for the idea of being permissive in the While it does appear invalid, in practice in the wild there are hosts starting with hyphens. For example, Although looking at the linked changeset, it looks like being more permissive is the direction we're going, so that's good! |
Because input domain names are assumed to be in common display format (as it is called in the current DNS Terminology draft), special processing is required for U+005C REVERSE SOLIDUS Accepting all remaining visible ASCII characters lacking special meaning in the DNS should be non-controversial, and in https://go-review.googlesource.com/c/go/+/73830 I also decided to allow just about every ASCII character when backslash-prefixed (but could be talked into changing the exact set). Regardless, it MUST be possible to specify any octet with |
I think that the desirable line is already described in RFC 6055. IMHO, at least the function isDomainName should be replaced with a series of LDHLabels, ASCIILabels and NetUnicodeLabels (I don't want to use the terminology of IDNA such as A-Label and U-Label here because NetUnicodeLabels might accept non-NFC UTF-8 or UTF-16/32 labels) functions and we probably should provide some control knob to users for choosing the namespace label encoding:
If you want to add more additional control knob for IDN support, that's probably fine, but please be careful not conflating NetUnicode or other UTF stuff and IDNA-valid U-labels. |
Change https://golang.org/cl/99623 mentions this issue: |
In kubernetes , isDomainName reject Pods "A Record" "pod-ip-address" , for example: "172-17-0-16", as RFC 3696 section 2 requires "top-level domain names not be all-numeric", but this example has three hyphen, so I think it should not be reject. |
@snowcrumble, I sent https://go-review.googlesource.com/c/go/+/136900 for that. |
Change https://golang.org/cl/136900 mentions this issue: |
From #17659 (comment) ... > In kubernetes , isDomainName reject Pods "A Record" "pod-ip-address", > for example: "172-17-0-16", as RFC 3696 section 2 requires > "top-level domain names not be all-numeric", but this example has > three hyphen, so I think it should not be reject. Updates #17659 Change-Id: Ibd8ffb9473d69c45c91525953c09c6749233ca20 Reviewed-on: https://go-review.googlesource.com/136900 Run-TryBot: Brad Fitzpatrick <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Gudger <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
RFC 1035 § 5 is about master files, which package net does not support. Is there another RFC that extends the requirement for supporting \DDD escapes to client resolver libraries like package net? |
Over the years, the ASCII syntax defined in that section has been generalized into what is now known as "presentation format"¹. As far as I know, it is the only valid text-safe means of representing an arbitrary domain name. When you say "package net does not support" it, I think you mean that it supports only a subset—and if that is indeed intentional, then the gap should be documented and the error messages should be normalized and corrected. But that seems like a mistake to me... what are the reasons for not allowing ¹ In the context of DNS, the earliest use of that term I could find is in in RFC 3658 (before that it was still "Master File Format" as in RFC 1706, with a transition beginning sometime around RFC 2535). |
I haven't been following this bug closely, but:
Obviously we weren't trying to make Lookup fail to resolve arbitrary domain names. More than likely we tried to add some validation somewhere and got it wrong and ended up too aggressive. |
I saw this guide to modern DNS recently which ignores all the old parts of DNS RFCs which are no longer accurate: https://powerdns.org/hello-dns/ Maybe the answer to this question is in there somewhere. |
Punycode exists because although any octet is permissible in a DNS label, there is no guidance on how to interpret octets 128 through 255. It is definitively not acceptable to assume that they are UTF-8, and any domain name including them, although valid, is not an Internet host name because it does not conform to the letter-digit-hyphen "preferred name syntax" (but note that underscore names such as But all of that, while interesting for background purposes, does not change the need to respect arbitrary octets in domain name labels as required by RFC 2181. I really don't know how to be more clear in demonstrating that such is the case. |
Hello, are there any new developments on this? |
isDomainName
is limited to hostname-compatible "preferred name" LDH labels, with an exception made for underscores per #1167. But RFC 2181 is clear about any octet being valid in a DNS label:What version of Go are you using (
go version
)?go1.7.1
What operating system and processor architecture are you using (
go env
)?linux/amd64
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build693750050=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
What did you do?
query uncommon domain names
What did you expect to see?
successful DNS queries
What did you see instead?
valid names were rejected
The text was updated successfully, but these errors were encountered: