-
Notifications
You must be signed in to change notification settings - Fork 107
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
fix(network): Ignore out of order Address Book changes, unless they are concurrent #6717
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6717 +/- ##
==========================================
- Coverage 78.14% 78.07% -0.08%
==========================================
Files 310 308 -2
Lines 40874 40958 +84
==========================================
+ Hits 31942 31978 +36
- Misses 8932 8980 +48 |
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 is looking great, thank you for fixing this.
I like the workaround for the imprecise timestamps (though I'd like to review it more thoroughly).
77e88e7
to
cf7f618
Compare
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.
Thank you!
Co-authored-by: Arya <[email protected]>
@oxarbitrage I'm going to go ahead and merge this PR now to avoid merge conflicts. Feel free to review it or skip the review, whatever you work out with Pili. |
Motivation
We want to ignore earlier address book changes which are delayed, so we don't accidentally reset the peer state to an earlier value. But some changes can be concurrent, so the change application order doesn't always match the network order.
Close #6672
Specifications
There is no formal specification for peer network behaviour, but in general, the peer's internal address book state should reflect the actual behaviour of its peers.
Complex Code or Requirements
This code runs concurrently, it is accessed from both the address book updater task and the candidate set peer dialler task.
Changes can arrive earlier or later than their network order because of:
The application can also independently initiate a change to the connection state, which can be simultaneous (or before) a change from the peer. In this case, the application-provided change needs to take priority. (Because it is typically failing the connection.)
Solution
Fix the code that applies changes to the address book, so that:
Refactor the code that applies changes so it is easier to read.
Add TODOs for further changes that are not required to fix this security issue.
Testing
There are existing tests for the other kinds of changes.
Review
This is one of the more complex audit changes that we have left to do. I'm happy to do a video review if that helps!
Reviewer Checklist
Follow Up Work
Make it much harder for remote peers to delay changes by flooding the change channel: