Ignore getaddr messages on Outbound connections. 251/head
authorIvan Pustogarov <ivanpustogarov@users.noreply.github.com>
Sun, 7 Dec 2014 16:30:57 +0000 (17:30 +0100)
committersvost <ya.nowa@yandex.ru>
Wed, 14 Oct 2015 08:29:48 +0000 (11:29 +0300)
The only time when a client sends a "getaddr" message is when he
esatblishes an Outbound connection (see ProcessMessage() in
src/main.cpp).  Another bitcoin client is expected to receive a
"getaddr" message only on Inbound connection. Ignoring "gettaddr"
requests on Outbound connections can resolve potential privacy issues
(and as was said such request normally do not happen anyway).

Rebased-From: dca799e1db6e319fdd47e0bfdb038eab0efabb85
Github-Pull: #5442

src/main.cpp

index 9ff24e4..b3c3504 100644 (file)
@@ -3619,7 +3619,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
     }
 
 
-    else if (strCommand == "getaddr")
+    // This asymmetric behavior for inbound and outbound connections was introduced
+    // to prevent a fingerprinting attack: an attacker can send specific fake addresses
+    // to users' AddrMan and later request them by sending getaddr messages. 
+    // Making users (which are behind NAT and can only make outgoing connections) ignore 
+    // getaddr message mitigates the attack.
+    else if ((strCommand == "getaddr") && (pfrom->fInbound))
     {
         // Don't return addresses older than nCutOff timestamp
         int64_t nCutOff = GetTime() - (nNodeLifespan * nOneDay);