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: infinite loop in LookupAddr() #34660
Comments
It looks like the problem is caused by a DNS response that includes the requested PTR record along with a RRSIG record. This patch fixes the problem for me: diff --git a/src/net/dnsclient_unix.go b/src/net/dnsclient_unix.go
index e0a7ef8552..ce59e7861a 100644
--- a/src/net/dnsclient_unix.go
+++ b/src/net/dnsclient_unix.go
@@ -765,6 +765,7 @@ func (r *Resolver) goLookupPTR(ctx context.Context, addr string) ([]string, erro
}
}
if h.Type != dnsmessage.TypePTR {
+ p.SkipAnswer()
continue
}
ptr, err := p.PTRResource()
I have a change request ready, but I have a couple questions first:
|
@gopherbot, please backport to Go 1.12 and Go 1.13. This looks like a DoS vector. |
Backport issue(s) opened: #34661 (for 1.12), #34662 (for 1.13). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
@mndrix, I can't reproduce with my DNS server(s). But the bug looks real & fix looks correct.
We have tests that work with in-memory fake servers. See |
Change https://golang.org/cl/198460 mentions this issue: |
Change https://golang.org/cl/198489 mentions this issue: |
Change https://golang.org/cl/198497 mentions this issue: |
If a request for a PTR record returned a response with a non-PTR answer, goLookupPTR would loop forever. Skipping non-PTR answers guarantees progress through the DNS response. Fixes #34662 Updates #34660 Change-Id: I56f9d21e5342d07e7d843d253267e93a29707904 Reviewed-on: https://go-review.googlesource.com/c/go/+/198460 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> (cherry picked from commit f0e940e) Reviewed-on: https://go-review.googlesource.com/c/go/+/198489 Reviewed-by: Michael Hendricks <michael@ndrix.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
If a request for a PTR record returned a response with a non-PTR answer, goLookupPTR would loop forever. Skipping non-PTR answers guarantees progress through the DNS response. Fixes #34661 Updates #34660 Change-Id: Ib5e5263243bc34b9e2f85aa2b913c9cd50dbcaa5 Reviewed-on: https://go-review.googlesource.com/c/go/+/198497 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
What did you see instead?
Hangs with 100% CPU.
The text was updated successfully, but these errors were encountered: