Musl's getaddrinfo cannot resolve peer names from Netbird's client DNS #953

Closed
opened 2025-11-20 05:20:31 -05:00 by saavagebueno · 4 comments
Owner

Originally created by @glaeqen on GitHub (Jun 5, 2024).

Describe the problem

Programs linked against muslc cannot resolve the peer name against a DNS provided by Netbird client . getaddrinfo with default addrinfo returns EAI_NONAME.

Musl's getaddrinfo with default settings (specifically addrinfo.af_family == AF_UNSPEC) asks for both A and AAAA entry. If any response contains a flag "No such name", error EAI_NONAME is returned. This behaviour is different in glibc. Relevant mailing list: https://www.openwall.com/lists/musl/2021/07/19/8

To Reproduce

Steps to reproduce the behavior:
0. Connect to a netbird network.

  1. $ docker run --network host -it alpine
  2. In a container: $ ping <valid-peer-domain-name>
  3. Failure occurs

You can also see that choosing to resolve only IPv4 works
$ ping -4 <valid-peer-name

Expected behavior

Proper peer name resolution. Not sure what Netbird's DNS should do but DNSes for example for github.com seem to respond with an empty response but a flag is "No error" instead of "No such name"? Not sure.

Thanks a lot.

Originally created by @glaeqen on GitHub (Jun 5, 2024). **Describe the problem** Programs linked against `muslc` cannot resolve the peer name against a DNS provided by Netbird client . `getaddrinfo` with default `addrinfo` returns `EAI_NONAME`. Musl's `getaddrinfo` with default settings (specifically `addrinfo.af_family == AF_UNSPEC`) asks for both `A` and `AAAA` entry. If *any* response contains a flag "No such name", error `EAI_NONAME` is returned. This behaviour is different in glibc. Relevant mailing list: https://www.openwall.com/lists/musl/2021/07/19/8 **To Reproduce** Steps to reproduce the behavior: 0. Connect to a netbird network. 1. `$ docker run --network host -it alpine` 2. In a container: `$ ping <valid-peer-domain-name>` 3. Failure occurs You can also see that choosing to resolve only IPv4 works `$ ping -4 <valid-peer-name` **Expected behavior** Proper peer name resolution. Not sure what Netbird's DNS should do but DNSes for example for `github.com` seem to respond with an empty response but a flag is "No error" instead of "No such name"? Not sure. Thanks a lot.
saavagebueno added the system-compatibility-issuetriage-needed labels 2025-11-20 05:20:31 -05:00
Author
Owner

@nazarewk commented on GitHub (Apr 23, 2025):

seems more like a musl implementation issue? It should pick the succesful response instead of defaulting to the one not available.

@glaeqen We have fixed some related A/AAAA DNS issues recently. Can you check the latest NetBird version to see if your specific issue was by any chance resolved?

@nazarewk commented on GitHub (Apr 23, 2025): seems more like a `musl` implementation issue? It should pick the succesful response instead of defaulting to the one not available. @glaeqen We have fixed some related `A`/`AAAA` DNS issues recently. Can you check the latest NetBird version to see if your specific issue was by any chance resolved?
Author
Owner

@glaeqen commented on GitHub (Jul 8, 2025):

Problem still occurs in the newest Netbird.

seems more like a musl implementation issue? It should pick the succesful response instead of defaulting to the one not available.

According to the musl maintainer this behaviour is a bug and undermines DNSSEC. There also a glibc bug issue tracker where (if I understand correctly) it is stated that a fix has been added in glibc 2.41 but is not enabled by default in order not to break existing deployments

Andreas K. Huettel 2024-12-20 23:42:57 UTC
See also (in 2.41):

commit 765325951ac5c7d072278c9424930b29657e9758
Author: Florian Weimer fweimer@redhat.com
AuthorDate: Wed Jul 24 12:06:47 2024 +0200
Commit: Florian Weimer fweimer@redhat.com
CommitDate: Wed Jul 24 12:10:37 2024 +0200

resolv: Implement strict-error stub resolver option (bug 27929)

For now, do not enable this mode by default due to the potential
impact on compatibility with existing deployments.

Reviewed-by: DJ Delorie <dj@redhat.com>

In musl wiki it is considered a glibc bug

musl also does not implement the following glibc bugs:
(...)

  • When getaddrinfo is called with AF_UNSPEC, glibc returns a result even if one of the address families returns ServFail. This is a bug (glibc #27929) and may undermine DNSSEC.

This would a QoL improvement for everyone that tries to query Netbird's DNS resolver from within musl-powered environments (eg. from Alpine Linux, very popular as a Docker base image or programs that statically link libc - where musl is the only viable option).

I'm not an expert but my spitballed suggestion

Not sure what Netbird's DNS should do but DNSes for example for github.com seem to respond with an empty response but a flag is "No error" instead of "No such name"? Not sure.

could be a solution?

I'm not in a rush to get this functionality or in a position to force Netbird team to do anything but figured you deserve the answer after a few months of silence :)

@glaeqen commented on GitHub (Jul 8, 2025): Problem still occurs in the newest Netbird. > seems more like a musl implementation issue? It should pick the succesful response instead of defaulting to the one not available. [According to the musl maintainer](https://www.openwall.com/lists/musl/2021/07/19/8) this behaviour is a bug and undermines DNSSEC. There also a [glibc bug issue tracker](https://sourceware.org/bugzilla/show_bug.cgi?id=27929) where (if I understand correctly) it is stated that a fix has been added in glibc 2.41 but is not enabled by default in order not to break existing deployments > > Andreas K. Huettel 2024-12-20 23:42:57 UTC > See also (in 2.41): > commit 765325951ac5c7d072278c9424930b29657e9758 > Author: Florian Weimer <fweimer@redhat.com> > AuthorDate: Wed Jul 24 12:06:47 2024 +0200 > Commit: Florian Weimer <fweimer@redhat.com> > CommitDate: Wed Jul 24 12:10:37 2024 +0200 > resolv: Implement strict-error stub resolver option (bug 27929) > > For now, do not enable this mode by default due to the potential > impact on compatibility with existing deployments. > > Reviewed-by: DJ Delorie <dj@redhat.com> [In musl wiki](https://github.com/Artoria2e5/musl-wiki/blob/master/functional-differences-from-glibc.md#name-resolverdns) it is considered a glibc bug > musl also does not implement the following glibc bugs: > (...) > - When getaddrinfo is called with AF_UNSPEC, glibc returns a result even if one of the address families returns ServFail. This is a bug (glibc #27929) and may undermine DNSSEC. This would a QoL improvement for everyone that tries to query Netbird's DNS resolver from within musl-powered environments (eg. from Alpine Linux, very popular as a Docker base image or programs that statically link libc - where musl is the only viable option). I'm not an expert but my spitballed suggestion > Not sure what Netbird's DNS should do but DNSes for example for github.com seem to respond with an empty response but a flag is "No error" instead of "No such name"? Not sure. could be a solution? I'm not in a rush to get this functionality or in a position to force Netbird team to do anything but figured you deserve the answer after a few months of silence :)
Author
Owner

@nazarewk commented on GitHub (Jul 8, 2025):

According to our developers, this is how it should work now as some time ago, we switched from returning NXDOMAIN to NOERROR for empty results. From what we understood, this is already what musl expects?

It works just fine for me podman run --rm -it --network=host alpine ping etra.netbird.cloud. when both machines are on 0.49.0.

Could you provide us with an example program demonstrating the issue?

@nazarewk commented on GitHub (Jul 8, 2025): According to our developers, this is how it should work now as some time ago, we switched from returning `NXDOMAIN` to `NOERROR` for empty results. From what we understood, this is already what `musl` expects? It works just fine for me `podman run --rm -it --network=host alpine ping etra.netbird.cloud.` when both machines are on `0.49.0`. Could you provide us with an example program demonstrating the issue?
Author
Owner

@glaeqen commented on GitHub (Sep 30, 2025):

Apologies, I updated everything then but the client on my PC. That's correct, peer names resolve correctly now.

Closing the issue (sorry that so late), thank you for all the responses 👍🏻

@glaeqen commented on GitHub (Sep 30, 2025): Apologies, I updated everything then _but_ the client on my PC. That's correct, peer names resolve correctly now. Closing the issue (sorry that so late), thank you for all the responses 👍🏻
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#953