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

connectd: bound the SOCKS5 request hostname to the request buffer

Public commit record

What the developer wrote

Authored by Níckolas Goline

73/100 · Adequate
connectd: bound the SOCKS5 request hostname to the request buffer

The SOCKS5 CONNECT request is built into a fixed 255-byte buffer, but a
domain-name request needs 7 + strlen(host) bytes and the host length was
never checked. A host longer than 248 bytes overran the buffer while the
request was assembled, corrupting the adjacent length field, which was then
used as the io_write() length and produced a large out-of-bounds read: the
proxy socket received connectd's heap instead of the request, and connectd
died. The host reaches this both from a proxied connect and from a gossiped
DNS address.

Size the buffer to hold the largest legal request (header plus a
maximum-length domain name), and refuse a hostname which still does not fit
rather than building a request we cannot represent. Truncating the host is
not an option: that is a connection to the wrong destination.

Changelog-Fixed: connectd: a proxied connection to a very long hostname (including a gossiped DNS address) could crash the node.
(cherry picked from commit 04ca809936794de47943951b9d116d9fd1ea1844)
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This update fixes a bug in Core Lightning's Tor/proxy connection code. When the node tried to connect through a SOCKS5 proxy to a hostname longer than 248 characters, it wrote past the end of a small fixed buffer. That corrupted the recorded message length, causing the proxy to be sent random data from the program's memory and crashing the node. The fix enlarges the buffer to the legal maximum and rejects hostnames that are still too long instead of overflowing.

Recommended action

Apply the patch and ensure the regression test test_connect_proxy_maxlen_hostname passes. Nodes using Tor/proxy outbound connections should upgrade, since a malicious or malformed long hostname can crash connectd.

Security signals we found

01

Stack buffer overflow / out-of-bounds write in SOCKS5 request construction

02

Out-of-bounds read caused by corrupted length used in io_write

03

Denial of service: connectd crash on long proxied hostname

04

Input from gossiped DNS address can reach the vulnerable code path

05

Changelog-Fixed explicitly describes the crash scenario

Risk score

Why this scored 73/100

Our methodology →
Potential impact 22/30
Exploitability 16/25
Stealth signal 10/15
Affected reach 11/15
Confidence 9/10
Evidence quality 5/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.