-
Notifications
You must be signed in to change notification settings - Fork 111
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
security(state): Limit the number of non-finalized chains tracked by Zebra #6447
Conversation
43c1b9d
to
4822ab0
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6447 +/- ##
==========================================
+ Coverage 77.78% 77.86% +0.07%
==========================================
Files 304 304
Lines 39637 39659 +22
==========================================
+ Hits 30833 30879 +46
+ Misses 8804 8780 -24 |
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.
This looks excellent!
Temporary network errors:
https://github.com/ZcashFoundation/zebra/actions/runs/4601125572/jobs/8128642182#step:5:15
|
Motivation
There is no limit on the number of non-finalized chains that Zebra can track.
Theoretically, this allows unbounded use of memory. But this bug is difficult to exploit on mainnet, because it would require mining hundreds of side-chain blocks at mainnet difficulty.
Specifications
The number of chains tracked by a node implementation is a standard rule, not a consensus rule. For
zcashd
, it is currently 1 in memory, and some number on disk.For Zebra, after this PR it will be 10 in memory. (Zebra doesn't store any unverified or side-chain blocks on disk.)
Complex Code or Requirements
This is concurrent code, the non-finalized state is cloned before reading it concurrently. We ensure that the limit of 10 is kept by making the list of chains into a private field, and only accessing them via a method.
Solution
Review
This is a low priority security fix.
Reviewer Checklist