-
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
fix: native restaking withdrawal checks could be bypassed #85
Conversation
…d to bypass native restaking withdrawal checks
WalkthroughThe changes introduce enhanced security measures in the Changes
Assessment against linked issues
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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
Outside diff range, codebase verification and nitpick comments (3)
src/core/LSTRestakingController.sol (1)
51-54
: Security enhancement in withdrawal function.The addition of
_getVault(token);
inwithdrawPrincipalFromExocore
function is a crucial security enhancement. It ensures that only tokens associated with a valid vault can be used, which indirectly prevents the use ofVIRTUAL_STAKED_ETH_ADDRESS
for unauthorized withdrawals.The code changes are approved.
Consider adding explicit error handling if the vault is not found, to provide clearer feedback to the user:
IVault vault = _getVault(token); require(address(vault) != address(0), "Invalid token: Vault not found");test/foundry/unit/ClientChainGateway.t.sol (2)
Line range hint
280-354
: Enhanced clarity in contract naming and comprehensive test coverage.The renaming of the contract to
WithdrawNonBeaconChainETHFromCapsule
follows Solidity's convention and enhances clarity. The test scenarios cover successful withdrawals and various failure modes effectively.The code changes are approved.
Consider adding more detailed comments for each test scenario to provide better context and understanding of the expected behaviors and conditions:
// Test to ensure successful withdrawal of non-beacon chain ETH from a capsule. function test_success_withdrawNonBeaconChainETH() public { ... } // Test to ensure the function reverts if the capsule is not found. function test_revert_capsuleNotFound() public { ... }
355-408
: Robust testing for new security measures in withdrawal scenarios.The
WithdrawalPrincipalFromExocore
contract provides comprehensive testing for the new security measures. It ensures that the withdrawal logic is robust and handles edge cases appropriately, such as whitelisting checks and zero amount withdrawals.The code changes are approved.
Enhance the clarity of test descriptions to better convey the purpose and expected outcomes of each test:
// Test to ensure the function reverts when attempting to withdraw a non-whitelisted token. function test_revert_withdrawNonWhitelistedToken() public { ... } // Test to ensure the function reverts when attempting to withdraw zero amount. function test_revert_withdrawZeroAmount() public { ... }
in this new commit, we forbid deploying vault for We should forbid deploying vault for |
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/Bootstrap.sol (1 hunks)
- src/core/ClientGatewayLzReceiver.sol (1 hunks)
- src/libraries/Errors.sol (1 hunks)
- src/storage/BootstrapStorage.sol (3 hunks)
- src/storage/ClientChainGatewayStorage.sol (1 hunks)
- test/foundry/unit/Bootstrap.t.sol (2 hunks)
Files skipped from review due to trivial changes (2)
- src/core/ClientGatewayLzReceiver.sol
- src/storage/ClientChainGatewayStorage.sol
Additional comments not posted (7)
src/libraries/Errors.sol (1)
210-211
: LGTM!The new error declaration
ForbidToDeployVault
is a valuable addition to theErrors
library. It follows the naming convention, is placed in the appropriate location, and has a clear error message. This error will enhance the error handling capabilities of the library and improve the clarity of the code when dealing with vault deployments related to staked ETH.src/storage/BootstrapStorage.sol (3)
8-9
: LGTM!The import statement for the
Errors
library is necessary and looks good.
151-152
: LGTM!The constant
VIRTUAL_STAKED_ETH_ADDRESS
is defined correctly and serves a clear purpose in the contract.
343-345
: LGTM!The if statement correctly prevents deploying vaults with the
VIRTUAL_STAKED_ETH_ADDRESS
token, enhancing the contract's security.src/core/Bootstrap.sol (1)
198-200
: LGTM!The added conditional check is necessary to prevent deploying a vault for the virtual token address representing natively staked ETH. It ensures that the vault deployment logic is skipped for this specific token, while allowing it for other tokens that don't have a vault yet.
test/foundry/unit/Bootstrap.t.sol (2)
68-68
: LGTM!The constant
VIRTUAL_STAKED_ETH_ADDRESS
is correctly defined and will be useful for handling the specific case related to the virtual token in the test suite.
180-192
: LGTM!The test
test02_VaultNotDeployedForNativeStakedETH
is correctly implemented and verifies that a vault is not deployed for the virtual staked ETH address. This improves the robustness of the contract by ensuring that the system correctly identifies and handles the virtual staked ETH scenario.
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 (1)
- test/mocks/NonShortCircuitEndpointV2Mock.sol (1 hunks)
Files skipped from review due to trivial changes (1)
- test/mocks/NonShortCircuitEndpointV2Mock.sol
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.
LGTM
Description
closes: #84
the solution is simple, before sending the withdrawal request to Exocore in
LSTRestakingController.withdrawPrincipalFromExocore
, we try to get corresponding vault for the specified token. If we could get the vault, the token cannot be VIRTUAL_STAKED_ETH_ADDRESS.Simply checking that the token being not equal to VIRTUAL_STAKED_ETH_ADDRESS is also a good approach, but
_getVault
could guarantee not only the token is LST token but also the vault existsSummary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Documentation