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

dnspython 2.6.0: timeout with DNS servers that worked fine with dnspython 2.5.0 #1053

Closed
felixfontein opened this issue Feb 18, 2024 · 7 comments

Comments

@felixfontein
Copy link

Describe the bug
This happened in the integration tests of the Ansible community.dns collection; I reduced it to the following minimal reproducer:

import dns
import dns.resolver

resolver = dns.resolver.Resolver(configure=False)
resolver.nameservers = ['198.51.44.8']  # IPv4 of dns1.p08.nsone.net., one of the github.com. nameservers
resolver.resolve(dns.name.from_unicode('github.com.'), lifetime=10, rdtype=dns.rdatatype.TXT)

With dnspython 2.5.0 this immediately returned a result. With dnspython 2.6.0, this times out after 10 seconds:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/path/to/python3.11/site-packages/dns/resolver.py", line 1321, in resolve
    timeout = self._compute_timeout(start, lifetime, resolution.errors)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/path/to/python3.11/site-packages/dns/resolver.py", line 1075, in _compute_timeout
    raise LifetimeTimeout(timeout=duration, errors=errors)
dns.resolver.LifetimeTimeout: The resolution lifetime expired after 11.601 seconds: Server Do53:198.51.44.8@53 answered The DNS operation timed out.; Server Do53:198.51.44.8@53 answered The DNS operation timed out.; Server Do53:198.51.44.8@53 answered The DNS operation timed out.; Server Do53:198.51.44.8@53 answered The DNS operation timed out.; Server Do53:198.51.44.8@53 answered The DNS operation timed out.

(lifetime can also be set to a lower value, for example 1 works fine for me with dnspython 2.5.0.)

To Reproduce
See the above reproducer

Context (please complete the following information):

  • dnspython version 2.6.0
  • Python version 3.11 (happens also with other Python verisons)
  • OS: Linux (various)
@felixfontein
Copy link
Author

git bisect points to f66e25b (Address DoS via the Tudoor mechanism (CVE-2023-29483)), which I guess isn't surprising :)

@rthalley rthalley added the Bug label Feb 18, 2024
@rthalley
Copy link
Owner

The problem here is that the Tudoor compensation code is eating the Truncated exception raised in this case, preventing us from failing over to TCP. I will fix this and do 2.6.1 soon, but I have to figure out how best to fix it first!

@rthalley
Copy link
Owner

I was able to replicate with your example and the tudoor-trunc branch I just pushed fixes it, but still preserves the desired Tudoor protection. I'll be merging and starting the release process soon.

rthalley added a commit that referenced this issue Feb 18, 2024
* The Tudoor fix should not eat valid Truncated exceptions [##1053]

* Make logic more readable
@rthalley rthalley added the Fixed label Feb 18, 2024
@felixfontein
Copy link
Author

@rthalley awesome, thank you very much! :)

rthalley added a commit that referenced this issue Feb 18, 2024
* The Tudoor fix should not eat valid Truncated exceptions [##1053]

* Make logic more readable

(cherry picked from commit 2ab3d16)
@felixfontein
Copy link
Author

I ran my CI with the latest main branch and it works fine.

@felixfontein
Copy link
Author

Resolved with the 2.6.1 release. Thanks a lot again @rthalley!

@rthalley
Copy link
Owner

Thank you for the report and good replication example!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants