NewsCrawler.org

Palindrome IP addresses hid a byte-order bug in the nmrs Rust library

nmrs is a Rust library for talking to NetworkManager[1] over D-Bus[2], and its author maintains it. In July 2026 it became the networking backend for COSMIC settings on Pop!_os. Soon after, a user reported that WireGuard[3] configs imported from services such as Proton or Mullvad brought the tunnel up and the handshake succeeded, but DNS did not resolve. Importing the same file with nmcli kept the DNS server as 10.2.0.1, so the bug was in nmrs.

The cause was the function that set the DNS servers. It converted each address with u32::from, which gives host byte order, while NetworkManager expects network byte order. On a little-endian[4] machine the lowest byte is stored first, so 10.2.0.1 sits in memory backwards and NetworkManager read it as 1.0.2.10. The fix builds the integer from the octets with u32::from_ne_bytes, so the byte order matches the local machine where NetworkManager also runs.

The bug went unnoticed for seven months because the existing test called the same conversion it was checking, and palindromic addresses such as 8.8.8.8 and 1.1.1.1 read the same in either byte order. The rewritten tests decode the value the way NetworkManager does and use addresses that are not palindromes. A second test checks the exact numeric value 0x0100_020A on little-endian machines.

Repository nmrs github.com

Rust library for managing NetworkManager connections over D-Bus, used as the networking backend for COSMIC settings.

Stars: 330Forks: 43License: Apache-2.0Updated:

Read the original cachebag.shDiscussion

Discussion

Most comments are short. One jokes that a new generation is learning about endianness, and another says a test with an IPv6 address would likely have caught the bug, since DNS resolvers are unlikely to use palindromic IPv6 addresses. A third notes that BSD sockets also take IP addresses and ports in network order, and a fourth criticizes the lowercase «i» used throughout the text.

Sources

Published: First seen: Читать по-русски

Open as a page