mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-24 14:51:11 +01:00
Reject SOCKS requests for "localhost" or ".local"
Sending them on is futile, since we will be told "127.0.0.1" and then think we've been lied to. Partial fix for 2822.
This commit is contained in:
parent
70c17134c7
commit
433d757846
4 changed files with 20 additions and 2 deletions
6
changes/bug2822.2
Normal file
6
changes/bug2822.2
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
o Minor features:
|
||||||
|
|
||||||
|
- Don't bother trying to connect to addresses that we are sure will
|
||||||
|
resolve to 127.0.0.1: Getting 127.0.0.1 in a reply makes us think
|
||||||
|
we have been lied to, even when the address the client tried to
|
||||||
|
connect to was "localhost." Partial fix for bug 2822.
|
|
@ -1682,3 +1682,12 @@ get_interface_address(int severity, uint32_t *addr)
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return true if we can tell that <b>name</b> is a canonical name for the
|
||||||
|
* loopback address. */
|
||||||
|
int
|
||||||
|
tor_addr_hostname_is_local(const char *name)
|
||||||
|
{
|
||||||
|
return !strcasecmp(name, "localhost") ||
|
||||||
|
!strcasecmp(name, "local") ||
|
||||||
|
!strcasecmpend(name, ".local");
|
||||||
|
}
|
||||||
|
|
|
@ -191,6 +191,8 @@ int tor_addr_is_loopback(const tor_addr_t *addr);
|
||||||
int tor_addr_port_split(int severity, const char *addrport,
|
int tor_addr_port_split(int severity, const char *addrport,
|
||||||
char **address_out, uint16_t *port_out);
|
char **address_out, uint16_t *port_out);
|
||||||
|
|
||||||
|
int tor_addr_hostname_is_local(const char *name);
|
||||||
|
|
||||||
/* IPv4 helpers */
|
/* IPv4 helpers */
|
||||||
int is_internal_IP(uint32_t ip, int for_listening);
|
int is_internal_IP(uint32_t ip, int for_listening);
|
||||||
int addr_port_lookup(int severity, const char *addrport, char **address,
|
int addr_port_lookup(int severity, const char *addrport, char **address,
|
||||||
|
|
|
@ -2000,8 +2000,9 @@ connection_ap_handshake_rewrite_and_attach(entry_connection_t *conn,
|
||||||
if (options->ClientRejectInternalAddresses &&
|
if (options->ClientRejectInternalAddresses &&
|
||||||
!conn->use_begindir && !conn->chosen_exit_name && !circ) {
|
!conn->use_begindir && !conn->chosen_exit_name && !circ) {
|
||||||
tor_addr_t addr;
|
tor_addr_t addr;
|
||||||
if (tor_addr_parse(&addr, socks->address) >= 0 &&
|
if (tor_addr_hostname_is_local(socks->address) ||
|
||||||
tor_addr_is_internal(&addr, 0)) {
|
(tor_addr_parse(&addr, socks->address) >= 0 &&
|
||||||
|
tor_addr_is_internal(&addr, 0))) {
|
||||||
/* If this is an explicit private address with no chosen exit node,
|
/* If this is an explicit private address with no chosen exit node,
|
||||||
* then we really don't want to try to connect to it. That's
|
* then we really don't want to try to connect to it. That's
|
||||||
* probably an error. */
|
* probably an error. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue