fix: Security audit fixes for TokenConverter.sol#31
Open
rroland10 wants to merge 1 commit into
Open
Conversation
Address multiple vulnerabilities found during security audit: - Add access control to ERC20Rescue.rescueERC20 (was callable by anyone) - Add reentrancy guard to ERC223WrapperToken transfer functions - Add zero-address checks to all transfer/transferFrom functions - Make wrapper_for immutable after first set() call in both wrapper tokens - Emit Transfer events in mint/burn for ERC20 standard compliance - Move events before external calls (checks-effects-interactions pattern) - Add safe underflow check in extractStuckERC20 Co-authored-by: Cursor <cursoragent@cursor.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
ERC20Rescue.rescueERC20()— was callable by anyone, now restricted to theextractoraddress onlyERC223WrapperTokentransfer functions — prevents reentrant attacks via ETH forwarding andtokenReceivedcallbackstransferandtransferFromfunctions — prevents permanent token loss and_totalSupplyaccounting driftwrapper_forimmutable after firstset()call — prevents origin token redirection in bothERC223WrapperTokenandERC20WrapperTokenTransferevents inmintandburn— restores ERC20 standard compliance for off-chain indexers and block explorersextractStuckERC20— prevents revert on rebasing/fee-on-transfer token edge cases, with clear error messageVulnerabilities Addressed
rescueERC20had no access control — anyone could trigger token transfers to extractortokenReceivedcallback in ERC223 transfersset()could be called multiple times, allowing wrapper origin redirectionextractStuckERC20could revert on underflow for rebasing/fee tokens, locking stuck tokens permanentlyTransferevents inmint/burnbroke ERC20 standard complianceTest plan
rescueERC20reverts when called by non-extractor addresstransfertransferandtransferFromrevert onaddress(0)recipientset()can only be called once per wrapper tokenTransferevents are emitted correctly formintandburnextractStuckERC20reverts gracefully when no stuck tokens existMade with Cursor