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

[Proxy/Client] Fix DNS server denial-of-service issue when DNS entry expires #15403

Merged

Conversation

lhotari
Copy link
Member

@lhotari lhotari commented Apr 30, 2022

Motivation

  • DnsNameResolver doesn't coordinate concurrency and this leads to DNS server DoS
    under high load to the Pulsar Proxy. This happens when a large number of connections are initiated at once.

Dns lookups will timeout since the DNS server will get overloaded and won't be able to respond in time.
Example error message query via UDP timed out after 5000 milliseconds:

 Caused by: io.netty.resolver.dns.DnsResolveContext$SearchDomainUnknownHostException: Failed to resolve 'pulsar-testenv-pulsar-broker-2.pulsar-testenv-pulsar-broker.pulsar-testenv.svc.cluster.local' and search domain query for configured domains failed as well: [pulsar-testenv.svc.cluster.local, svc.cluster.local, cluster.local]
 	at io.netty.resolver.dns.DnsResolveContext.finishResolve(DnsResolveContext.java:1047) ~[io.netty-netty-resolver-dns-4.1.76.Final.jar:4.1.76.Final]
 	... 22 more
 Caused by: io.netty.resolver.dns.DnsNameResolverTimeoutException: [/172.30.183.10:53] query via UDP timed out after 5000 milliseconds (no stack trace available)
  • In Netty, DnsAddressResolverGroup internally uses internal InflightNameResolver
    class to address the problem

Modification

  • use DnsAddressResolverGroup instead of instantiating DnsNameResolver directly

Additional context

Similar issue in AsyncHttpClient: AsyncHttpClient/async-http-client#1650
Netty issue netty/netty#5838

…expires

- DnsNameResolver doesn't coordinate concurrency and this leads to DNS server DoS
  under high load
- In Netty, DnsAddressResolverGroup internally uses internal InflightNameResolver
  class to address the problem
  - The solution is to use DnsAddressResolverGroup instead of instantiating DnsNameResolver
    directly
@lhotari lhotari added type/bug The PR fixed a bug or issue reported a bug area/client area/proxy doc-not-needed Your PR changes do not impact docs release/2.9.3 release/2.8.4 release/2.10.1 labels Apr 30, 2022
@lhotari lhotari added this to the 2.11.0 milestone Apr 30, 2022
@lhotari lhotari self-assigned this Apr 30, 2022
Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

+1

Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@Technoboy- Technoboy- merged commit 40d7169 into apache:master May 3, 2022
lhotari added a commit to datastax/pulsar that referenced this pull request May 3, 2022
…expires (apache#15403)

- DnsNameResolver doesn't coordinate concurrency and this leads to DNS server DoS
  under high load
- In Netty, DnsAddressResolverGroup internally uses internal InflightNameResolver
  class to address the problem
  - The solution is to use DnsAddressResolverGroup instead of instantiating DnsNameResolver
    directly
lhotari added a commit to datastax/pulsar that referenced this pull request May 3, 2022
lhotari added a commit to datastax/pulsar that referenced this pull request May 3, 2022
@michaeljmarshall
Copy link
Member

I'm a bit late, but LGTM.

nicoloboschi pushed a commit to datastax/pulsar that referenced this pull request May 10, 2022
codelipenghui pushed a commit that referenced this pull request May 20, 2022
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label May 20, 2022
codelipenghui pushed a commit that referenced this pull request May 20, 2022
mattisonchao pushed a commit that referenced this pull request May 25, 2022
@mattisonchao mattisonchao added the cherry-picked/branch-2.9 Archived: 2.9 is end of life label May 25, 2022
lhotari added a commit that referenced this pull request Jun 1, 2022
…expires (#15403)

- DnsNameResolver doesn't coordinate concurrency and this leads to DNS server DoS
  under high load
- In Netty, DnsAddressResolverGroup internally uses internal InflightNameResolver
  class to address the problem
  - The solution is to use DnsAddressResolverGroup instead of instantiating DnsNameResolver
    directly

(cherry picked from commit fe78908)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/client area/proxy cherry-picked/branch-2.8 Archived: 2.8 is end of life cherry-picked/branch-2.9 Archived: 2.9 is end of life cherry-picked/branch-2.10 doc-not-needed Your PR changes do not impact docs release/2.8.4 release/2.9.3 release/2.10.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants