-
-
Notifications
You must be signed in to change notification settings - Fork 425
fix: don't try to serve states for future slots #8665
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
Conversation
Summary of ChangesHello @nflaig, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a critical security enhancement by preventing beacon nodes from attempting to serve state data for future blockchain slots. Previously, requesting a state for a slot far ahead of the current head could lead to an unbounded amount of computational work, making the node vulnerable to Denial-of-Service attacks. The changes ensure that any such requests are immediately rejected with a "not found" error, thereby safeguarding the node's resources and stability. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request correctly addresses a potential denial-of-service vulnerability by preventing state lookups for future slots. The logic is sound and the change is targeted. I have one suggestion to refactor the nested ternary operators into a more readable if/else structure, which should improve the maintainability of the code.
Performance Report✔️ no performance regression detected Full benchmark results
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## unstable #8665 +/- ##
=========================================
Coverage 52.02% 52.02%
=========================================
Files 848 848
Lines 65837 65834 -3
Branches 4811 4810 -1
=========================================
- Hits 34250 34249 -1
+ Misses 31518 31516 -2
Partials 69 69 🚀 New features to boost your workflow:
|
|
🎉 This PR is included in v1.38.0 🎉 |
Motivation
When requesting a future slot the node tries to dial the state from head which allows to quite easily DoS the node as it's unbounded amount of work if the slot is very far away from head.
We should not allow to request states that are in the future (> clock slot) and return a 404 instead.
Description
In case state is request by slot, check if it's a slot from the future based on clock slot and return 404 state not found error.
I didn't use
forkChoice.getHead().slotbecause we should still be able to serve the state if all slots between the requested slot and the head slot are skipped.Related discord discussion, thanks to @guha-rahul for catching and reporting this.