Bug 33802 (CVE-2026-0915) - Uninitialized stack buffer used as DNS query name when net==0 in _nss_dns_getnetbyaddr_r
Summary: Uninitialized stack buffer used as DNS query name when net==0 in _nss_dns_get...
Status: RESOLVED FIXED
Alias: CVE-2026-0915
Product: glibc
Classification: Unclassified
Component: network (show other bugs)
Version: 2.43
: P2 normal
Target Milestone: ---
Assignee: Carlos O'Donell
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2026-01-15 21:56 UTC by Carlos O'Donell
Modified: 2026-01-16 14:27 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:
carlos: security+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos O'Donell 2026-01-15 21:56:15 UTC
**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
Comment 1 Carlos O'Donell 2026-01-15 21:57:37 UTC
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.
Comment 2 Carlos O'Donell 2026-01-15 22:05:08 UTC
The impacted APIs are getnetbyaddr and getnetbyaddr_r.
Comment 3 Carlos O'Donell 2026-01-15 22:10:13 UTC
Patch posted to the list https://inbox.sourceware.org/libc-alpha/20260115220945.1904095-1-carlos@redhat.com/T/#u
Comment 4 Carlos O'Donell 2026-01-15 22:24:04 UTC
(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.
Comment 6 Carlos O'Donell 2026-01-16 14:27:24 UTC
Fixed on master with https://sourceware.org/cgit/glibc/commit/?id=e56ff82d5034ec66c6a78f517af6faa427f65b0b