|
|
Message-ID: <CAJZkTRcj42kZpCbrevgJOYptSqfd+epkC-q=2dPuZtJptayP8g@mail.gmail.com>
Date: Sat, 28 Nov 2026 17:43:17 +0800
From: X L <idealeer521@...il.com>
To: musl@...ts.openwall.com, dalias@...hyderm.io
Subject: musl: stub resolver queries from an unconnected UDP socket are
poisonable off-path on Linux 7.1+
Dear there,
We are researchers at Nankai University working on the security of LLM
agents. We found some issues in your product. Please feel free to check
them.
Summary
__res_msend_rc() sends DNS queries from one UDP socket that is bound to an
ephemeral port but not connected, because the same socket talks to every
configured name server. On Linux, an off-path attacker can find that port
while the lookup is pending: probes to closed ports draw ICMP
port-unreachable errors, while the probe to the open port does not.
Until 2026 this did not matter in practice. musl keeps the port for only 5
s (options timeout, default 5, split into 2 attempts of 2.5 s on the same
socket). Under the old Linux defaults, a scan of the 28,232-port ephemeral
range took about 30 s. In February 2026, Linux raised its global ICMP error
limit tenfold (commit 64db5933c7ad, released in v7.1). The scan now takes
about 2.2 s, and the 65,536 forged responses for every TxID take about 0.25
s more.
In our tests, under the old kernel defaults the attack failed in 4 of 4
attempts. Under the new defaults it succeeded in 20 of 20, taking 3.1 s on
average. A program that calls getaddrinfo() received the attacker's address.
DetailsMechanism
1.
The UDP socket is created and bound to port 0 (socket() and bind() in
res_msend.c), so the kernel picks a port from ip_local_port_range
(32768โ60999 by default). It is not connected.
2.
The query (and one retry after 2.5 s) is sent with sendto() to each name
server. A probe from any address to the socket's port is accepted, and a
probe to any other port draws an ICMP error.
3.
Responses are accepted from any configured server address (the source
address is checked in user space), so forged responses carrying the name
server's source address are accepted, provided the TxID and question match.
4.
A response with a wrong TxID does not end the lookup, so the attacker
can send all 65,536 TxIDs.
The only kernel mechanism that slows step 2 is the global ICMP error limit (
net.ipv4.icmp_msgs_per_sec). Under the new defaults (10000/s, burst 10000),
a scan of the default range fits easily into 5 s. The attacker needs a few
thousand source addresses over IPv4, or one IPv6 prefix.
Measurements
Isolated testbed. The kernel was 7.0.14, with the victim's network
namespace set to the old (1000/50) or the new (10000/10000) defaults. A
test program called getaddrinfo() for a random name under a test zone whose
name server did not answer. We measured windows of 5.00โ5.07 s.
Old defaults New defaults
Success 0/4 20/20
Mean scan time ~30 s (exceeds the 5 s window) 2.16 s
Mean attack time โ 3.1 sExposure
musl is the C library of Alpine Linux and of many minimal container images.
In such a container, every program that resolves a name uses this code. On
a host running Linux v7.1 or later, a new container's network namespace
starts with the new defaults, whatever the host's sysctl.conf says.
The attacker must be able to trigger a lookup in the victim, for example by
making a service resolve an attacker-chosen name, and must be able to send
packets that spoof the name server's address.
Suggested fixes
1.
*Use one connected UDP socket per name server.* The kernel then answers
probes from other addresses with ICMP errors, and the port cannot be
observed. This is the fix SAD DNS (Man et al., ACM CCS 2020, ยง8)
recommended. We understand that this changes the single-socket design of
__res_msend_rc().
2.
Alternatively, end the attempt on a response that matches the server and
question but not the TxID. This leaves the attacker one guess per lookup,
at the cost of letting a spoofed packet abort a lookup.
3.
Shortening options timeout is not a reliable mitigation. At timeout:2
the window is 2 s, only slightly above the 1.82 s minimum scan time.
Workarounds for users
-
Use a local caching resolver that connects its upstream sockets, or a
resolver reached over TCP or TLS.
-
Drop outgoing ICMP port-unreachable errors in the container's network
namespace.
References
-
K. Man et al., "DNS Cache Poisoning Attack Reloaded: Revolutions with
Side Channels," ACM CCS 2020.
-
Linux commit 64db5933c7ad, "icmp: increase
net.ipv4.icmp_msgs_{per_sec,burst}" (v7.1).
Xiang Li
AOSP Lab @Nankai University
Content of type "text/html" skipped
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.