bugfix: send shortened IPv6 addresses to SOCKS5 proxies in full #36675

pull instagibbs wants to merge 1 commits into bitcoin:master from instagibbs:2026-10-socks5-ipv6-expand changing 3 files +80 −3
  1. instagibbs commented at 2:30 PM on October 27, 2026: member

    Found while auditing #36628

    Already known upstream issue with C-tor: https://gitlab.torproject.org/tpo/core/tor/-/issues/32314

    With -proxy pointed at Tor, outbound connections to IPv6 peers whose address contains an inner :: always fail with "general failure".

    Core sends every SOCKS5 destination as a DOMAINNAME, with IPv6 in its compressed form. Tor copies the name into its relay BEGIN cell as <name>:<port>, and the exit's tor_addr_port_split first tries to parse the whole string as an IPv6 address. 2001:db8::1:8333 is a valid one, because the :: absorbs the port as an eighth group. The exit then sees no port and closes the stream. Addresses written with all eight groups, or ending in ::, are unaffected: appending :port to them does not give a valid address.

    About 20% of the IPv6 addresses in a gossip-filled addrman, and 29% of current IPv6 DNS seed answers, have an inner ::. The failure is closed; there is no fallback to a direct connection.

    Note that this also effects private broadcast by default.

    This PR sends such addresses with all eight groups written out (2001:db8:0:0:0:0:0:1). <name>:<port> then has nine groups, so the exit splits at the last colon. Other forms:

    Form Tor Tor, SafeSocks 1 getaddrinfo-based proxies
    2001:db8::1 (today) fails fails works
    [2001:db8::1] works works fails
    ATYP IPv6 works, logs a DNS-leak warning refused works
    eight groups (this PR) works works works

    Tested against tor 0.4.9.13: on mainnet, master could not reach four seed-provided peers with inner-:: addresses (30 "general failure"); with this change all four connected and completed the version handshake. feature_proxy.py and a new netbase_tests case check the bytes sent.

  2. DrahtBot commented at 2:31 PM on October 27, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    Concept ACK darosior

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. darosior commented at 2:46 PM on October 27, 2026: member

    Workaround seems fine to do. But it's surprising the Tor daemon does not follow its own spec and format the IPv6 with brackets.

    EDIT: had bot lookup the Tor sources and even the latest version still formats IPv6:port ambiguously, contrary to the spec. Arti does implement the spec correctly. May be worth upstreaming a bug report.

  4. netbase: send shortened IPv6 addresses to SOCKS5 proxies in full
    Tor copies a SOCKS5 DOMAINNAME into its relay BEGIN cell as
    "<name>:<port>", and an exit parses "2001:db8::1:8333" as an IPv6
    address with no port and closes the stream. Outbound connections
    through a Tor -proxy to IPv6 addresses that contain "::" therefore fail
    with "general failure". About a third of the IPv6 addresses the DNS
    seeds return have this form.
    
    Write such addresses with all eight groups. "<name>:<port>" is then not
    an IPv6 address, so the exit splits it at the last colon, and the name
    is still an address to proxies that resolve it with getaddrinfo, which
    brackets would break.
    721e2f5051
  5. instagibbs force-pushed on Oct 27, 2026
  6. DrahtBot added the label CI failed on Oct 27, 2026
  7. instagibbs commented at 2:58 PM on October 27, 2026: member

    @darosior https://gitlab.torproject.org/tpo/core/tor/-/issues/32314 already known and closed. "Just use Arti"

  8. darosior commented at 3:01 PM on October 27, 2026: member

    Concept ACK

  9. DrahtBot removed the label CI failed on Oct 27, 2026
  10. instagibbs renamed this:
    netbase: send shortened IPv6 addresses to SOCKS5 proxies in full
    bugfix: send shortened IPv6 addresses to SOCKS5 proxies in full
    on Oct 27, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-30 15:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me