net: Fix Discover() not running when using -bind=0.0.0.0:port
What changed, and why it matters
This change fixes a bug in Bitcoin Core where the software would not automatically discover and advertise its own internet-facing IP addresses when a user configured it to listen on all network interfaces using the specific syntax '-bind=0.0.0.0:port'. Without this discovery, the node could become harder for other peers to find and connect to, potentially reducing its connectivity and network resilience. The fix makes the discovery logic also check explicit bind and whitebind configurations for the 'any address' pattern, not just the general listen-on-any setting.
Treat as a low-severity availability/networking bug. Backport to maintained branches if the affected code path exists there, because operators using -bind=0.0.0.0:<port> expect inbound connectivity comparable to default listening. No immediate emergency response is warranted; no remote code execution or consensus vulnerability is evident from the diff.
Security signals we found
P2P network reachability degradation when using explicit any-address bind
Potential eclipse/partitioning risk from reduced inbound connectivity
Node may fail to advertise routable IPs, affecting network topology health
Fixes logic gap between bind_on_any flag and explicit -bind/-whitebind any-address configurations
Evidence from the diff
In src/init.cpp, the Discover() call was gated solely on connOptions.bind_on_any. However, when a user passes -bind=0.0.0.0:
Changed components
src/init.cppP2P networking initializationCConnman connection options (connOptions.vBinds, vWhiteBinds, bind_on_any)Discover() local IP discovery routineInspect captured patch +20 / −1
diff --git a/src/init.cpp b/src/init.cpp
index e6cc2045..9c22c3c5 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -2140,7 +2140,26 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
StartTorControl(onion_service_target);
}
- if (connOptions.bind_on_any) {
+ bool should_discover = connOptions.bind_on_any;
+ if (!should_discover) {
+ for (const auto& bind : connOptions.vBinds) {
+ if (bind.IsBindAny()) {
+ should_discover = true;
+ break;
+ }
+ }
+ }
+
+ if (!should_discover) {
+ for (const auto& whitebind : connOptions.vWhiteBinds) {
+ if (whitebind.m_service.IsBindAny()) {
+ should_discover = true;
+ break;
+ }
+ }
+ }
+
+ if (should_discover) {
// Only add all IP addresses of the machine if we would be listening on
// any address - 0.0.0.0 (IPv4) and :: (IPv6).
Discover();
Why this scored 34/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.