net: Don't log own ips during discover
What changed, and why it matters
This change stops Bitcoin Core from writing the computer's own internet addresses to log files unless the user has turned on the -logips option. Previously, the software logged these addresses even when -logips was off, which could leak private network information in shared logs or backups. The fix is a straightforward privacy improvement, not a fix for an active attack.
No urgent action. Users who share debug logs or run nodes in environments where local IP disclosure is sensitive should ensure -logips remains unset (default) and consider reviewing existing logs for leaked local addresses. Developers should verify no other local-address logging bypasses fLogIPs.
Security signals we found
Information disclosure via debug logs: local IP addresses logged without explicit user consent
Inconsistent enforcement of -logips privacy option
Privacy hardening in P2P networking layer
Evidence from the diff
The patch gates three local-address log statements behind the existing fLogIPs flag in src/net.cpp: AddLocal, RemoveLocal, and Discover. Previously these functions logged local interface addresses regardless of the -logips setting, causing potential unintended disclosure of local IP addresses in debug logs. The change is defensive and privacy-oriented; it does not alter network behavior, routing, or peer selection.
Changed components
src/net.cppAddLocal()RemoveLocal()Discover()-logips option handlingInspect captured patch +9 / −3
diff --git a/src/net.cpp b/src/net.cpp
index 16591461..ec4944c8 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -287,7 +287,9 @@ bool AddLocal(const CService& addr_, int nScore)
if (!g_reachable_nets.Contains(addr))
return false;
- LogInfo("AddLocal(%s,%i)\n", addr.ToStringAddrPort(), nScore);
+ if (fLogIPs) {
+ LogInfo("AddLocal(%s,%i)\n", addr.ToStringAddrPort(), nScore);
+ }
{
LOCK(g_maplocalhost_mutex);
@@ -310,7 +312,10 @@ bool AddLocal(const CNetAddr &addr, int nScore)
void RemoveLocal(const CService& addr)
{
LOCK(g_maplocalhost_mutex);
- LogInfo("RemoveLocal(%s)\n", addr.ToStringAddrPort());
+ if (fLogIPs) {
+ LogInfo("RemoveLocal(%s)\n", addr.ToStringAddrPort());
+ }
+
mapLocalHost.erase(addr);
}
@@ -3345,8 +3350,9 @@ void Discover()
return;
for (const CNetAddr &addr: GetLocalAddresses()) {
- if (AddLocal(addr, LOCAL_IF))
+ if (AddLocal(addr, LOCAL_IF) && fLogIPs) {
LogInfo("%s: %s\n", __func__, addr.ToStringAddr());
+ }
}
}
Why this scored 29/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.