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

Ignore Path MTU Discovery on UDP server socket #7410

Merged
merged 2 commits into from Apr 23, 2019

Conversation

rgacogne
Copy link
Member

Short description

It might help prevent Path MTU poisoning attacks.
Untested, don't merge it yet!

Checklist

I have:

  • read the CONTRIBUTING.md document
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)

#endif /* IP_PMTUDISC_OMIT */

/* IP_PMTUDISC_DONT disables Path MTU discovery */
SSetsockopt(sockfd, IPPROTO_IP, IP_MTU_DISCOVER, IP_PMTUDISC_DONT);
Copy link
Member Author

@rgacogne rgacogne Jan 23, 2019

Choose a reason for hiding this comment

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

We should check that IP_MTUDISC_DONT is defined. Note that unbound sets the don't fragment flag on systems that don't have IP_MTUDISC_DONT: https://github.com/NLnetLabs/unbound/blob/master/services/listen_dnsport.c#L571

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Added the missing check for IP_MTUDISC_DONT. I'm still undecided about setting DF=1.

@rgacogne
Copy link
Member Author

As a datapoint, Knot decided against doing this: https://gitlab.labs.nic.cz/knot/knot-dns/issues/467

@mnordhoff
Copy link
Contributor

Knot decided against it in 2016 when fragmentation attacks weren't in vogue, though.

@rgacogne
Copy link
Member Author

Rebased to fix a conflict.

@rgacogne
Copy link
Member Author

rgacogne commented Apr 4, 2019

As pointed out by @hdais NSD did bite the bullet as well recently: https://www.nlnetlabs.nl/bugs-script/show_bug.cgi?id=4235

@rgacogne
Copy link
Member Author

Move this PR into the rec-4.2.0-beta1 milestone. Now is the time to speak if you are against this change ;-)

@rgacogne rgacogne merged commit aecec57 into PowerDNS:master Apr 23, 2019
@rgacogne rgacogne deleted the pmtu-dont branch April 23, 2019 08:29
@jedisct1
Copy link

jedisct1 commented Mar 26, 2020

Hi Remi,

That change seems to be what made DNSCrypt servers running dnsdist unreliable after they upgraded to version 1.4.0.

As you know since you implemented the protocol, DNSCrypt requires questions sent over UDP to be as large as responses, using padding.

Blocking fragmented questions prevents large responses from being received.

Ignoring fragments in responses from authoritative servers is fine, but even with unencrypted queries, I'm not sure that there is any value in dropping fragments on the server socket. A fragment attack would just allow the question to be modified, but a stub resolver would ignore a response for a different query.

@rgacogne
Copy link
Member Author

Hi Frank,

Thanks a lot for reporting this! I have to admit I had completely forgotten that propriety of DNSCrypt when I submitted this change, sorry about that!
I'll re-evaluate whether it makes sense to keep setting setSocketIgnorePMTU() on our incoming sockets. At the very least I'll disable it for DNSCrypt binds.

@jedisct1
Copy link

Thank you so much Remi!

/cc @welwood08

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

Successfully merging this pull request may close these issues.

None yet

3 participants