To be clear, the problem to warn about is when an application is using a fundamentally unsafe variant of socks -- e.g. socks4 rather than socks4a, or socks5-with-ip-address rather than socks5-with-fqdn.
If the application is correctly using socks5-with-fqdn, yet the address that gets asked for is a string that happens to be an ipv4 address, I think everything is going according to plan.
(I acknowledge that there could be edge cases where the user has set up some complex machinery to do resolves some other unsafe way, and then pass them to an application that does the correct sort of variant of socks. But I don't think it's our place for Tor to warn in that case.)
#10165 (moved) is related. So neither "localhost" nor 127.0.0.1 should work in Tor Browser because of possible leakage? (Also in the comments to #10165 (moved) that led to this ticket, why is an (alleged) online banking site trying to open those connections to 127.0.0.1?)
Is the goal here that a user-provided numeric IP address won't generate warnings? (on the assumption the user knows what they're doing?)
#10165 (moved) is related. So neither "localhost" nor 127.0.0.1 should work in Tor Browser because of possible leakage?
Yes, but I think that's separate from this ticket.
(Tor Browser removes the "no proxy for" values for localhost and 127.0.0.1, since allowing anything in the "wide open proxy bypass here" settings seemed poor. So if you visit 127.0.0.1 in Tor Browser, it dutifully passes the address to Tor like any other address, and then Tor says
Jun 02 16:16:15.000 [warn] Rejecting SOCKS request for anonymous connection to private address [scrubbed].
assuming you've left ClientRejectInternalAddresses set to 1. All of that is normal I think.)
(Also in the comments to #10165 (moved) that led to this ticket, why is an (alleged) online banking site trying to open those connections to 127.0.0.1?)
That is a fine and good question. I had originally thought that the 127.0.0.1 was the address of the application connection, i.e. "I received a tcp connection to the socksport, and the tcp info for the connection says it was from localhost and this high-numbered port". But looking more at the code, I think you're right that indeed something made that person's Tor make a big pile of connections to 127.0.0.1. I think so long as the person hadn't messed with their torrc even more, though, the ClientRejectInternalAddresses check would make Tor fail those requests.
Is the goal here that a user-provided numeric IP address won't generate warnings? (on the assumption the user knows what they're doing?)
Yes, the goal of this ticket is that if you type in http://128.31.0.34/ in your Tor Browser, it should not tell you that you're using an unsafe variant of the socks protocol. Because you're not -- you're using a safe variant of the socks protocol to ask for a legitimate web address.
(I think ordinary Tor Browser users would not see this controller level warning event, since there is no easy way in the interface to expose the controller events to ordinary users. Same with the Tor warning log messages. But that UX side is also a separate issue. :)
I think we need to go farther. The patch above still refuses a naked IP address when it's presented using a safe socks version, and that's still a bug. I think we want this:
Using the example from the ticket description, I'm still able to reproduce the issue on the current master branch. Found this while trying to debug #22572 (moved).
Ok so after getting clarifications from arma, the bottom line is that tor should NOT warn if we have a SOCKS5 hostname + IP address that is ATYP 0x03 with an IPv4/6 address. Application should always use tor that way if they did get an IP address from the user in the first place and no DNS resolution happened.
Tor is doing that correctly, only warning for IPv4/v6 atyp + IP string.
Torsocks is the one not doing that correctly (#23667 (moved)).
Trac: Status: reopened to closed Resolution: N/Ato fixed