-
Notifications
You must be signed in to change notification settings - Fork 5
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-enhance: add ReentrancyGuard to contracts #35
Conversation
Warning Review failedThe pull request is closed. WalkthroughThe recent changes introduce the Changes
Sequence Diagram(s)No sequence diagrams needed due to the nature of the changes. Assessment against linked issues
Poem
Tip Early access features: enabledWe are currently testing the following features in early access:
Note:
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- src/core/BaseRestakingController.sol (4 hunks)
- src/core/Bootstrap.sol (1 hunks)
- src/core/ClientChainGateway.sol (2 hunks)
- src/core/ExocoreGateway.sol (4 hunks)
- src/core/LSTRestakingController.sol (4 hunks)
- src/core/NativeRestakingController.sol (4 hunks)
Additional comments not posted (21)
src/core/LSTRestakingController.sol (5)
11-16
: The inheritance ofReentrancyGuardUpgradeable
is correctly implemented to enhance security against reentrancy attacks.
24-24
: The addition of thenonReentrant
modifier to thedeposit
function is appropriate given that it involves external calls and state changes which could be susceptible to reentrancy attacks.
41-41
: ThenonReentrant
modifier onwithdrawPrincipalFromExocore
is correctly applied, protecting against potential reentrancy vulnerabilities during the withdrawal process.
56-56
: Applying thenonReentrant
modifier towithdrawRewardFromExocore
is crucial for preventing reentrancy attacks during reward withdrawal operations.
72-72
: ThenonReentrant
modifier ondepositThenDelegateTo
function ensures that the delegation process is protected against reentrancy, which is particularly important given the external interactions in this function.src/core/BaseRestakingController.sol (4)
11-15
: The inheritance ofReentrancyGuardUpgradeable
inBaseRestakingController
is correctly implemented, aligning with best practices for securing contracts against reentrancy attacks.
30-30
: ThenonReentrant
modifier on theclaim
function is aptly added to safeguard the claiming process, which involves external calls and critical state changes.
50-50
: Correct application of thenonReentrant
modifier ondelegateTo
function to mitigate potential reentrancy issues during the delegation of responsibilities.
65-65
: The inclusion of thenonReentrant
modifier onundelegateFrom
ensures the security of the undelegation process from reentrancy attacks, especially given the external interactions involved.src/core/NativeRestakingController.sol (4)
11-16
: Inheritance ofReentrancyGuardUpgradeable
inNativeRestakingController
is correctly implemented, ensuring enhanced security against reentrancy attacks.
27-27
: ThenonReentrant
modifier on thestake
function is appropriately added to protect the staking process from reentrancy vulnerabilities, especially given the external interactions and state changes involved.
64-64
: Proper use of thenonReentrant
modifier indepositBeaconChainValidator
to secure the deposit process against potential reentrancy attacks.
81-81
: ThenonReentrant
modifier is correctly applied to bothprocessBeaconChainPartialWithdrawal
andprocessBeaconChainFullWithdrawal
, ensuring these sensitive operations are protected from reentrancy attacks.Also applies to: 88-88
src/core/ClientChainGateway.sol (2)
87-87
: The initialization ofReentrancyGuard
(__ReentrancyGuard_init_unchained
) in theClientChainGateway
constructor is correctly implemented, ensuring that the contract is protected from the start.
123-123
: Application of thenonReentrant
modifier onaddWhitelistTokens
is crucial for preventing reentrancy attacks during the token whitelisting process, which could involve multiple state changes and external interactions.src/core/ExocoreGateway.sol (5)
25-25
: Import ofReentrancyGuardUpgradeable
is correctly placed and follows Solidity's best practices for import ordering.
31-31
: Inheritance fromReentrancyGuardUpgradeable
is correctly added to enable the use of thenonReentrant
modifier in necessary functions.
65-65
: The call to__ReentrancyGuard_init_unchained()
is appropriately placed in theinitialize
function to ensure the reentrancy guard is initialized before any interactions.
100-100
: The addition of thenonReentrant
modifier tomarkBootstrapOnAllChains
is crucial for preventing reentrancy attacks, especially since this function interacts with external contracts.
151-157
: The application of thenonReentrant
modifier to_lzReceive
, an internal function overridden to handle incoming LayerZero messages, is a critical security enhancement. Ensure that any external interaction patterns within this function are reviewed for potential reentrancy vectors.src/core/Bootstrap.sol (1)
84-84
: The initialization ofReentrancyGuardUpgradeable
in theinitialize
function of theBootstrap
contract is correctly implemented. This setup ensures that the reentrancy guard is active before any state-changing operations occur.
Should we add a slither CI ? |
Tip For best results, initiate chat on the files or code changes. @adu-web3, I've created the issue to add Slither CI to the CI/CD pipeline as you requested. You can track the progress and further details here: Issue #38. Analysis chainScripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Create a GitHub issue for adding Slither CI to the CI/CD pipeline
gh issue create \
--title "Add Slither CI to the CI/CD pipeline" \
--body "This issue is to track the addition of Slither, a static analysis tool, to our CI/CD pipeline to enhance security by regularly checking for vulnerabilities as discussed in https://github.com/ExocoreNetwork/exocore-contracts/pull/35." \
--assignee adu-web3
Length of output: 388 |
@MaxMustermann2 have created the issue, don't worry, I'll close it |
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.
it looks good.
…odifier to user facing functions
017a22a
to
0ffef9d
Compare
Description
closes: #28
slither complains about some reentrancy issues though most of external calls our contracts make are calling whitelisted token contracts. It's better that we add
ReentrancyGuard
to existing contracts, especially contracts that provide user facing functions and addnonReentrant
modifier to those functions that would make external calls(to some ERC20 token, or even to layerzero endpoint).Summary by CodeRabbit
New Features
Improvements
nonReentrant
modifier in key functions to prevent reentrancy attacks.Security
ReentrancyGuardUpgradeable
to various contracts for increased security measures.