mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 13:42:10 +02:00
net: ensure no direct private broadcast connections
Private broadcast connections use either Tor or I2P, which require a proxy intrinsically or IPv4 or IPv6 which must use a proxy in the context of private broadcast to avoid leaking the originator's IP address. Add a safety check to guard against future mistakes. Co-authored-by: Andrew Toth <andrewstoth@gmail.com>
This commit is contained in:
@@ -488,8 +488,11 @@ CNode* CConnman::ConnectNode(CAddress addrConnect,
|
||||
LogDebug(BCLog::PROXY, "Using proxy: %s to connect to %s\n", use_proxy->ToString(), target_addr.ToStringAddrPort());
|
||||
sock = ConnectThroughProxy(*use_proxy, target_addr.ToStringAddr(), target_addr.GetPort(), proxyConnectionFailed);
|
||||
} else {
|
||||
// no proxy needed (none set for target network)
|
||||
sock = ConnectDirectly(target_addr, conn_type == ConnectionType::MANUAL);
|
||||
// No proxy needed (none set for target network). Private broadcast connections
|
||||
// must always use a proxy, otherwise they would leak the originator's IP address.
|
||||
if (Assume(conn_type != ConnectionType::PRIVATE_BROADCAST)) {
|
||||
sock = ConnectDirectly(target_addr, conn_type == ConnectionType::MANUAL);
|
||||
}
|
||||
}
|
||||
if (!proxyConnectionFailed) {
|
||||
// If a connection to the node was attempted, and failure (if any) is not caused by a problem connecting to
|
||||
|
||||
@@ -188,13 +188,19 @@ FUZZ_TARGET(connman, .init = initialize_connman)
|
||||
conn_type = ConnectionType::OUTBOUND_FULL_RELAY;
|
||||
}
|
||||
|
||||
std::optional<Proxy> proxy_override;
|
||||
if (conn_type == ConnectionType::PRIVATE_BROADCAST || fuzzed_data_provider.ConsumeBool()) {
|
||||
proxy_override.emplace(ConsumeService(fuzzed_data_provider));
|
||||
}
|
||||
|
||||
connman.OpenNetworkConnection(
|
||||
/*addrConnect=*/random_address,
|
||||
/*fCountFailure=*/fuzzed_data_provider.ConsumeBool(),
|
||||
/*grant_outbound=*/{},
|
||||
/*pszDest=*/fuzzed_data_provider.ConsumeBool() ? nullptr : random_string.c_str(),
|
||||
/*conn_type=*/conn_type,
|
||||
/*use_v2transport=*/fuzzed_data_provider.ConsumeBool());
|
||||
/*use_v2transport=*/fuzzed_data_provider.ConsumeBool(),
|
||||
/*proxy_override=*/proxy_override);
|
||||
},
|
||||
[&] {
|
||||
connman.SetNetworkActive(fuzzed_data_provider.ConsumeBool());
|
||||
|
||||
Reference in New Issue
Block a user