fix: [FIND-070] _replaceTokenHolder Zero-Index Corruption#1187
Merged
Conversation
Signed-off-by: jaime-iobermudez <jaime.bermudez@io.builders>
Signed-off-by: jaime-iobermudez <jaime.bermudez@io.builders>
mamoralesiob
approved these changes
May 25, 2026
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.
This pull request adds an important audit fix to the ERC1410 token holder management logic by ensuring that
replaceTokenHoldercorrectly checks for the existence of the old token holder before attempting replacement. It also introduces a mock contract to facilitate direct testing of internal storage wrapper functions and adds comprehensive tests to verify the new guard logic.Audit fix and testing improvements:
ERC1410StorageWrapper.replaceTokenHolderto revert withTokenHolderNotFoundif theoldTokenHolderdoes not exist (i.e., its index is zero), preventing accidental corruption of the token holder registry.TokenHolderNotFoundcustom error to theIERC1410Typesinterface for clearer revert reasons.Testing infrastructure:
MockERC1410StorageWrapper, a test-only contract that exposes internal functions ofERC1410StorageWrapperfor direct unit testing, bypassing the diamond infrastructure.SecurityHolders.test.tsto use the new mock contract and added tests that verify the new existence guard inreplaceTokenHolder, including cases where the holder was never registered or was removed. [1] [2]Type of change
Testing
Node version:
Checklist