You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Zebra can send a transaction gossip to half its peers for every transaction it verifies. This could put a lot of load on the network if transaction rates increase.
This helps with the following tickets, but doesn't completely resolve any of them:
After this change, new blocks and transactions are gossiped immediately, but then the next gossip is delayed for 6 seconds, and any pending changes are combined:
2023-05-07T23:44:14.798961Z INFO {zebrad="e426f63" net="Main"}: zebrad::components::mempool::gossip: sending mempool transaction broadcast request=AdvertiseTransactionIds(4) changes=1
2023-05-07T23:44:15.038166Z INFO {zebrad="e426f63" net="Main"}:{peer=Out("162.19.139.183:8233")}:msg_as_req{msg="inv"}:inbound:download_and_verify{hash=000000000067b02b015bccab67b49a0979145b9b685076c2897343706cd8e9e1}: zebrad::components::inbound::downloads: downloaded and verified gossiped block height=Height(2078266)
2023-05-07T23:44:25.046703Z INFO {zebrad="e426f63" net="Main"}: zebrad::components::mempool::gossip: sending mempool transaction broadcast request=AdvertiseTransactionIds(7) changes=4
2023-05-07T23:44:31.048226Z INFO {zebrad="e426f63" net="Main"}: zebrad::components::mempool::gossip: sending mempool transaction broadcast request=AdvertiseTransactionIds(3) changes=3
2023-05-07T23:44:37.049697Z INFO {zebrad="e426f63" net="Main"}: zebrad::components::mempool::gossip: sending mempool transaction broadcast request=AdvertiseTransactionIds(3) changes=2
2023-05-07T23:44:43.050632Z INFO {zebrad="e426f63" net="Main"}: zebrad::components::mempool::gossip: sending mempool transaction broadcast request=AdvertiseTransactionIds(1) changes=1
2023-05-07T23:44:49.052259Z INFO {zebrad="e426f63" net="Main"}: zebrad::components::mempool::gossip: sending mempool transaction broadcast request=AdvertiseTransactionIds(1) changes=1
2023-05-07T23:45:09.622233Z INFO {zebrad="e426f63" net="Main"}: zebrad::components::mempool::gossip: sending mempool transaction broadcast request=AdvertiseTransactionIds(1) changes=1
teor2345
changed the title
fix(security): Rate-limit and size-limit peer gossip messages
fix(security): Rate-limit and size-limit peer transaction gossip messages
May 9, 2023
teor2345
changed the title
fix(security): Rate-limit and size-limit peer transaction gossip messages
fix(security): Rate-limit and size-limit peer transaction ID messages
May 9, 2023
A-concurrencyArea: Async code, needs extra work to make it work properly.A-diagnosticsArea: Diagnosing issues or monitoring performanceA-mempoolArea: Memory pool transactionsA-networkArea: Network protocol updates or fixesC-bugCategory: This is a bugC-securityCategory: Security issuesI-remote-node-overloadZebra can overload other nodes on the networkI-remote-triggerRemote nodes can make Zebra do something badI-usabilityZebra is hard to understand or useNU-5Network Upgrade: NU5 specific tasks
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Zebra can send a transaction gossip to half its peers for every transaction it verifies. This could put a lot of load on the network if transaction rates increase.
This helps with the following tickets, but doesn't completely resolve any of them:
inv
denial of service: Document consensus rules from Zcash spec: 4.5 Output Descriptions #3217Specifications
Zcash network messages are limited to 2MB.
Gossip behaviour is implementation-specific.
The larger wide transaction ID inventory gossip message size of 68 bytes is documented in:
https://zips.z.cash/zip-0239#deployment
Complex Code or Requirements
This code modifies a channel shared between concurrent async tasks.
Solution
Fixes - network message size:
zcashd
: Reduce MAX_INV_SZ so wtx invs fit within a network message zcash/zcash#6643MAX_TX_INV_IN_SENT_MESSAGE
in the network layer for gossips and responsesFixes - network message rate-limits:
Docs:
Testing:
Review
This is a routine security fix. It doesn't have to go into the next release, but if we have time to review it, it would be nice to get it in.
Reviewer Checklist
Follow Up Work
Rate-limit other kinds of network messages if they become an issue.