-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(network): Track misbehaving peer connections and ban them past a threshold #9201
Draft
arya2
wants to merge
6
commits into
main
Choose a base branch
from
score-misbehaving-peers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Add a `bans_by_ip` field to `AddressBook` - Update the `AddressBook::update()` method to: - increment misbehavior scores in its entries, - add addr ips to bans_by_ip if the score is excessive, - remove any addrs at the banned ip - Avoid responding to `GetAddr` requests with addresses of misbehaving peers (return None from `sanitized()`), - Avoid new inbound or outbound connections to banned ips
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-mempool
Area: Memory pool transactions
A-network
Area: Network protocol updates or fixes
C-bug
Category: This is a bug
C-enhancement
Category: This is an improvement
C-feature
Category: New features
C-security
Category: Security issues
I-heavy
Problems with excessive memory, disk, or CPU usage
I-invalid-data
Zebra relies on invalid or untrusted data, or sends invalid data
P-Medium ⚡
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 should drop connections to and avoid reconnecting with peers which advertise blocks or mempool transactions that fail some semantic validation checks.
Will close #9111.
This is a draft PR as it's still missing a test.
Solution
Channels:
Type Updates:
misbehavior_score
field onMetaAddr
, abans_by_ip
field toAddressBook
, and aUpdateMisbehavior
variant toMetaAddrChange
MetaAddrChange.apply_to_meta_addr()
to applyUpdateMisbehavior
changesPeerSocketAddr
of the peer that provided a block or transaction to theTransaction
andBlock
variants of the peer set's response typeDownloads
components to include the peer address from which the block or transaction originatedMethod Updates:
AddressBook.update()
to remove any addresses that exceed a misbehavior score threshold and add them tobans_by_ip
bans_by_ip
exceeds its maximum sizeby_addr
field avoids attempting outbound connections to them as candidates,sanitized()
method to avoid providing addresses with a non-zero misbehavior score in responses toGetAddr
requestsmisbehavior_score()
andmempool_misbehavior_score()
methods onTransactionError
,VerifyBlockError
, andBlockError
UpdateMisbehavior
messages to the address book updater when blocks or transactions fail some checks during semantic validationpoll_ready()
method to drop connections to banned IPsTests
This PR still needs tests.
Follow Up Work
Increment the misbehaviour score for more errors and adjust the amounts based on zcashd (though at a glance, it looks similar already).
PR Author's Checklist
PR Reviewer's Checklist