Skip to content

Commit

Permalink
Merge pull request #5841
Browse files Browse the repository at this point in the history
cae488d p2p: reject incoming connections to self (moneromooo-monero)
  • Loading branch information
luigi1111 committed Sep 9, 2019
2 parents 2129000 + cae488d commit 8693872
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/p2p/net_node.inl
Expand Up @@ -2318,6 +2318,15 @@ namespace nodetool

network_zone& zone = m_network_zones.at(context.m_remote_address.get_zone());

// test only the remote end's zone, otherwise an attacker could connect to you on clearnet
// and pass in a tor connection's peer id, and deduce the two are the same if you reject it
if(arg.node_data.peer_id == zone.m_config.m_peer_id)
{
LOG_DEBUG_CC(context, "Connection to self detected, dropping connection");
drop_connection(context);
return 1;
}

if (zone.m_current_number_of_in_peers >= zone.m_config.m_net_config.max_in_connection_count) // in peers limit
{
LOG_WARNING_CC(context, "COMMAND_HANDSHAKE came, but already have max incoming connections, so dropping this one.");
Expand All @@ -2344,7 +2353,7 @@ namespace nodetool
context.m_in_timedsync = false;
context.m_rpc_port = arg.node_data.rpc_port;

if(arg.node_data.peer_id != zone.m_config.m_peer_id && arg.node_data.my_port && zone.m_can_pingback)
if(arg.node_data.my_port && zone.m_can_pingback)
{
peerid_type peer_id_l = arg.node_data.peer_id;
uint32_t port_l = arg.node_data.my_port;
Expand Down

0 comments on commit 8693872

Please sign in to comment.