**Details** When `_nss_dns_getnetbyaddr_r` receives `net==0`: 1. The loop `for (cnt = 4; net2 != 0; ...)` never executes (net2=0 fails condition) 2. `cnt` remains 4 3. The switch statement has cases 0-3 but **no case 4 or default** 4. `qbuf[1025]` is never initialized 5. Uninitialized stack bytes are sent to the DNS server as the query name Vulnerable code in `resolv/nss_dns/dns-network.c`: ```c net2 = (uint32_t) net; for (cnt = 4; net2 != 0; net2 >>= 8) net_bytes[--cnt] = net2 & 0xff; switch (cnt) { case 3: sprintf (qbuf, "0.0.0.%u.in-addr.arpa", ...); break; case 2: sprintf (qbuf, "0.0.%u.%u.in-addr.arpa", ...); break; case 1: sprintf (qbuf, "0.%u.%u.%u.in-addr.arpa", ...); break; case 0: sprintf (qbuf, "%u.%u.%u.%u.in-addr.arpa", ...); break; // NO case 4! qbuf remains uninitialized } anslen = __res_context_query (ctx, qbuf, ...); // Leaks stack to DNS ``` **Reproduction** ```c #include <netdb.h> int main() { getnetbyaddr(0, AF_INET); return 0; } ``` Reported-by: Igor Morgenstern, Aisle Research
The glibc security team evaluated this to have security impact. There is no known application impact. The scenario where stack contents are leaked requires an application calling gethostbyaddr with net 0x0 and an attacker being able to control when that occurs in the calling thread to lead the stack contents. This is very complex and unlikely to occur.
The impacted APIs are getnetbyaddr and getnetbyaddr_r.
Patch posted to the list https://inbox.sourceware.org/libc-alpha/20260115220945.1904095-1-carlos@redhat.com/T/#u
(In reply to Carlos O'Donell from comment #1) > The glibc security team evaluated this to have security impact. > > There is no known application impact. > > The scenario where stack contents are leaked requires an application calling > gethostbyaddr with net 0x0 and an attacker being able to control when that Should be "getnetbyaddr". Apologies. > occurs in the calling thread to lead the stack contents. This is very > complex and unlikely to occur.
v2 posted: https://inbox.sourceware.org/libc-alpha/20260116125553.677866-1-carlos@redhat.com/T/#u
Fixed on master with https://sourceware.org/cgit/glibc/commit/?id=e56ff82d5034ec66c6a78f517af6faa427f65b0b