Skip to content

fix(solidity): apply CEI pattern to memo contracts#322

Merged
danwt merged 1 commit intomain-dymfrom
danwt/solidity-patches
Nov 18, 2025
Merged

fix(solidity): apply CEI pattern to memo contracts#322
danwt merged 1 commit intomain-dymfrom
danwt/solidity-patches

Conversation

@danwt
Copy link
Copy Markdown

@danwt danwt commented Nov 18, 2025

Summary

Fixes reentrancy vulnerabilities in HypERC20CollateralMemo and HypERC20Memo by applying the Checks-Effects-Interactions (CEI) pattern.

Changes

  • HypERC20CollateralMemo: Move memo read/delete before safeTransferFrom() external call
  • HypERC20Memo: Move memo read/delete before _burn() call
  • Add security comments explaining the CEI pattern and why it's necessary

Security Context

The vulnerability is conditional - only exploitable when:

  • Wrapped tokens have callbacks (ERC777, custom hooks)
  • Malicious or compromised token contracts
  • Upgradeable proxies that could add hooks later

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

  • ✅ Prettier formatting applied
  • ✅ No linting errors
  • ✅ Changes preserve existing functionality

Resolves dymensionxyz/hyperlane-deployments#85

🤖 Generated with Claude Code

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>
@danwt danwt merged commit 5e5fe86 into main-dym Nov 18, 2025
3 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant