-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Security fix 1 - drop unknown getdata messages #312
Security fix 1 - drop unknown getdata messages #312
Conversation
PR 18808 - Drop unknown types in getdata PR 19109 - Only allow getdata of recently announced invs
@@ -298,6 +299,7 @@ def on_reject(self, message): pass | |||
def on_sendcmpct(self, message): pass | |||
def on_sendheaders(self, message): pass | |||
def on_tx(self, message): pass | |||
#def on_notfound(self, message): pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to add this commented out line.
src/net_processing.cpp
Outdated
@@ -44,6 +45,10 @@ | |||
static constexpr int64_t ORPHAN_TX_EXPIRE_TIME = 20 * 60; | |||
/** Minimum time between orphan transactions expire time checks in seconds */ | |||
static constexpr int64_t ORPHAN_TX_EXPIRE_INTERVAL = 5 * 60; | |||
/** How long to cache transactions in mapRelay for normal relay */ | |||
static constexpr std::chrono::seconds RELAY_TX_CACHE_TIME = std::chrono::minutes{15}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constant you added is unreferenced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, even in bitcoin it's not used. It was defined by PR 18808. But after the logic was changed, this became unused. I'll remove it.
src/net_processing.cpp
Outdated
@@ -251,6 +265,9 @@ struct CNodeState { | |||
*/ | |||
bool fSupportsDesiredCmpctVersion; | |||
|
|||
//! A rolling bloom filter of all announced tx CInvs to this peer. | |||
CRollingBloomFilter vRecentlyAnnouncedInvs = CRollingBloomFilter{INVENTORY_MAX_RECENT_RELAY, 0.000001}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping the name the same makes it easier to track changes in Bitcoin.
CRollingBloomFilter vRecentlyAnnouncedInvs = CRollingBloomFilter{INVENTORY_MAX_RECENT_RELAY, 0.000001}; | |
CRollingBloomFilter m_recently_announced_invs = CRollingBloomFilter{INVENTORY_MAX_RECENT_RELAY, 0.000001}; |
src/net_processing.cpp
Outdated
} | ||
|
||
CTransactionRef tx = FindTxForGetData(pfrom, inv.hash, mempool_req, now); | ||
int nSendFlags = (inv.type == MSG_TX ? SERIALIZE_TRANSACTION_NO_WITNESS : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like Bitcoin, put it inside the if(tx) branch, otherwise it will not be used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry, I don't understand the change. do you mean move the variable int nSendFlags
inside if?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes.
…edInvs to m_recently_announced_invs
6dd7081
to
ca0bf4d
Compare
Port fixes from bitcoin:
PR 18808 - Drop unknown types in getdata
PR 19109 - Only allow getdata of recently announced invs
Add functional test to verify that unknown get data does not halt the peer and transitions that were not in recently announced invs are not replied