AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
High 71 Bitcoin

connectd: never block the io loop on DNS resolution

Public commit record

What the developer wrote

Authored by cdecker

73/100 · Adequate
connectd: never block the io loop on DNS resolution

Resolving a DNS address announced in a node_announcement used to call
getaddrinfo() directly, on connectd's single io thread. A slow or
unresponsive nameserver held up every peer on the machine for the
duration of the lookup: ~10s per query with glibc defaults, enough to
trip the 60s ping-liveness check and disconnect all peers.

getaddrinfo() now runs in a forked child which writes the results
back over a pipe; connectd reads the pipe from its io loop and
resumes the connect attempt from a loop callback, so the io thread
never waits on resolution. Keeping libc for the actual lookup
preserves /etc/hosts, search domains, systemd-resolved and
AI_ADDRCONFIG ordering exactly, and keeps DNS packet parsing out of
connectd itself.

A 30-second cap covers each lookup end to end (a wedged child is
killed), and at most ten resolvers run at once: a gossip-driven
reconnect storm queues the excess FIFO rather than forking without
bound. Before resolving, the child closes every fd it inherited: a
wedged child must not keep peer connections alive, nor pin EOF on
another lookup's pipe with its copy of that write end.

The connect RPC resolved a host name the same way, with a blocking
getaddrinfo() in lightningd's main loop, and ignored --disable-dns.
It now hands the unresolved name to connectd as a DNS address, which
goes through the same asynchronous resolver and honours
--disable-dns (unless a proxy resolves names for us).

Reported-by: Vincenzo Palazzo
Changelog-Fixed: connectd: a stalling DNS name in a peer's announced address no longer freezes all peer traffic; resolution is now done asynchronously.
Changelog-Changed: `connect` with a host name now resolves it asynchronously in connectd, and fails with `--disable-dns`.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit fixes a denial-of-service weakness in Core Lightning's connection daemon. Previously, when the node needed to look up a peer's internet address from a domain name, it did that lookup directly in its main networking thread. A slow or malicious DNS server could freeze all peer traffic for about 10 seconds per lookup, potentially disconnecting every peer. The fix moves DNS lookups into separate child processes and reads the results back without blocking the main loop. It also makes the `connect` RPC command use the same non-blocking path and respect the `--disable-dns` setting.

Recommended action

Treat this as a security-hardening fix with denial-of-service relevance. Users and operators should upgrade to a release containing this commit, especially nodes with many peers or exposure to untrusted gossiped DNS addresses. Review fork/child resource limits and monitor for any regressions in DNS resolution behavior or connect RPC semantics.

Security signals we found

01

Synchronous DNS lookup on single io thread caused global stall

02

Slow or malicious nameserver could disconnect all peers via ping timeout

03

Fix moves resolution to forked child with async pipe I/O

04

Adds 30-second timeout and 10-concurrent-resolver limit

05

Child closes inherited file descriptors to avoid pinning peer sockets or pipes

06

connect RPC now respects --disable-dns for hostname resolution

Risk score

Why this scored 71/100

Our methodology →
Potential impact 20/30
Exploitability 15/25
Stealth signal 12/15
Affected reach 12/15
Confidence 8/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.