fix(solidity): apply CEI pattern to memo contracts#322
Merged
Conversation
Fix reentrancy vulnerabilities in HypERC20CollateralMemo and HypERC20Memo by following Checks-Effects-Interactions pattern. Read and clear _memo state BEFORE external calls to prevent reentrancy attacks when tokens have callbacks (ERC777, custom hooks). Changes: - HypERC20CollateralMemo: move memo read/delete before safeTransferFrom - HypERC20Memo: move memo read/delete before _burn - Add security comments explaining the CEI pattern Resolves dymensionxyz/hyperlane-deployments#85 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes reentrancy vulnerabilities in HypERC20CollateralMemo and HypERC20Memo by applying the Checks-Effects-Interactions (CEI) pattern.
Changes
safeTransferFrom()external call_burn()callSecurity Context
The vulnerability is conditional - only exploitable when:
With standard ERC20 tokens (USDC, WETH, DAI), the vulnerability is not exploitable. However, applying the CEI pattern is defense-in-depth and prevents future misuse.
Testing
Resolves dymensionxyz/hyperlane-deployments#85
🤖 Generated with Claude Code