#895903 [torsocks] AAAA replies from Tor not handled

Package:
torsocks
Source:
torsocks
Description:
use SOCKS-friendly applications with Tor
Submitter:
Kevin Steen
Date:
2025-03-05 00:51:02 UTC
Severity:
important
Tags:
#895903#5
Date:
2018-04-17 12:55:43 UTC
From:
To:
torsocks version : 2.2.0-1+deb9u1

Tor now returns IPv6 addresses when hostnames are resolved, but torsocks
cannot handle this case.

To reproduce:
     torsocks -d nc ipv6.test-ipv6.com 80

[I'm using torsocks against the SOCKS5 proxy in TorBrowser.]

This makes it tricky to report bugs using
    torsocks reportbug-ng
as bugs.debian.org will sometimes resolve to a AAAA, causing the whole
program to abort with no error message.

#895903#14
Date:
2018-11-27 14:17:00 UTC
From:
To:
Hi,

thank you for this bug report. I confirm this behavior and thus I've
forwarded it to Tor's bugtracker.

Cheers
Ulrike

#895903#19
Date:
2018-11-27 15:44:00 UTC
From:
To:
This seems to be due to a limit in torsocks that has not yet been
resolved upstream: to resolve an IPv6 address, Tor must listen on the
IPv6 SocksPort and the request must be sent to this SocksPort. As far as
i understand it.

#895903#24
Date:
2021-01-06 01:42:14 UTC
From:
To:
Without torsocks nc(1) can't perform this request too.

$ nc ipv6.test-ipv6.com 80
ipv6.test-ipv6.com: forward host lookup failed: Unknown host
$ host ipv6.test-ipv6.com
ipv6.test-ipv6.com has IPv6 address 2001:470:1:18::115

This is because nc appears to be using gethostbyname()

1609896026 DEBUG torsocks[27929]: [gethostbyname] Requesting ipv6.test-ipv6.com hostname (in tsocks_gethostbyname() at gethostbyname.c:68)

which can't handle AAAA records.

There is getaddrinfo(3) which is implemented in torsocks. Unfortunately
AF_INET6 appears not to be supported yet. If you look at
tsocks_tor_resolve() in src/lib/torsocks.c, you will find a stub [1].

[1] https://github.com/dgoulet/torsocks/blob/d4b0a84bdf2a1895c8ec3091dc2767fd9f8c2d66/src/lib/torsocks.c#L527