Skip to content

Commit 2b1e383

Browse files
committed
Fix --anonymous-inbound data leak
1 parent 58a1d54 commit 2b1e383

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

external/trezor-common

Submodule trezor-common updated 265 files

src/p2p/net_node.inl

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2474,6 +2474,7 @@ namespace nodetool
24742474

24752475
//fill response
24762476
const epee::net_utils::zone zone_type = context.m_remote_address.get_zone();
2477+
const bool is_public = (zone_type == epee::net_utils::zone::public_);
24772478
network_zone& zone = m_network_zones.at(zone_type);
24782479

24792480
//will add self to peerlist if in same zone as outgoing later in this function
@@ -2483,26 +2484,38 @@ namespace nodetool
24832484
std::vector<peerlist_entry> local_peerlist_new;
24842485
zone.m_peerlist.get_peerlist_head(local_peerlist_new, true, max_peerlist_size);
24852486

2487+
/* Tor/I2P nodes receiving connections via forwarding (from tor/i2p daemon)
2488+
do not know the address of the connecting peer. This is relayed to them,
2489+
iff the node has setup an inbound hidden service. The other peer will have
2490+
to use the random peer_id value to link the two. My initial thought is that
2491+
the inbound peer should leave the other side marked as `<unknown tor host>`,
2492+
etc., because someone could give faulty addresses over Tor/I2P to get the
2493+
real peer with that identity banned/blacklisted.
2494+
2495+
\note Insert into `local_peerlist_new` so that it is only sent once like
2496+
the other peers. */
2497+
if(outgoing_to_same_zone)
2498+
local_peerlist_new.push_back(
2499+
peerlist_entry{zone.m_our_address, zone.m_config.m_peer_id, (is_public ? std::time(nullptr) : 0)}
2500+
);
2501+
24862502
//only include out peers we did not already send
24872503
rsp.local_peerlist_new.reserve(local_peerlist_new.size());
24882504
for (auto &pe: local_peerlist_new)
24892505
{
24902506
if (!context.sent_addresses.insert(pe.adr).second)
24912507
continue;
24922508
rsp.local_peerlist_new.push_back(std::move(pe));
2509+
2510+
if (!is_public)
2511+
rsp.local_peerlist_new.back().last_seen = 0;
24932512
}
24942513
m_payload_handler.get_payload_sync_data(rsp.payload_data);
24952514

2496-
/* Tor/I2P nodes receiving connections via forwarding (from tor/i2p daemon)
2497-
do not know the address of the connecting peer. This is relayed to them,
2498-
iff the node has setup an inbound hidden service. The other peer will have
2499-
to use the random peer_id value to link the two. My initial thought is that
2500-
the inbound peer should leave the other side marked as `<unknown tor host>`,
2501-
etc., because someone could give faulty addresses over Tor/I2P to get the
2502-
real peer with that identity banned/blacklisted. */
2503-
2504-
if(outgoing_to_same_zone)
2505-
rsp.local_peerlist_new.push_back(peerlist_entry{zone.m_our_address, zone.m_config.m_peer_id, std::time(nullptr)});
2515+
// randomize so location of local inbound is not easily found
2516+
std::shuffle(
2517+
rsp.local_peerlist_new.begin(), rsp.local_peerlist_new.end(), crypto::random_device{}
2518+
);
25062519

25072520
LOG_DEBUG_CC(context, "COMMAND_TIMED_SYNC");
25082521
return 1;

0 commit comments

Comments
 (0)