fix(RedactCore): reject zero address in deployConfidentialERC20#53
Open
amathxbt wants to merge 1 commit intoFhenixProtocol:masterfrom
Open
fix(RedactCore): reject zero address in deployConfidentialERC20#53amathxbt wants to merge 1 commit intoFhenixProtocol:masterfrom
deployConfidentialERC20#53amathxbt wants to merge 1 commit intoFhenixProtocol:masterfrom
Conversation
dployConfidentialERC20 is permissionlessly callable by anyone. Without a zero-address check, a caller can pass address(0) as the ERC20 token, which successfully deploys a ConfidentialERC20 proxy (ConfidentialERC20 .initialize only checks that the token is not itself an FHERC20) and registers the mapping entry address(0) → proxy. This permanently occupies the zero-address slot in EnumerableMap and can never be removed, and any future code that checks whether address(0) has a confidential wrapper would receive a non-zero result, causing silent misbehaviour. Add a revert with the new InvalidERC20 error.
Contributor
|
@amathxbt is attempting to deploy a commit to the Fhenix Team on Vercel. A member of the Team first needs to authorize it. |
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
deployConfidentialERC20is a permissionless factory function — anyone can call it. It currently checks only that the token is not WETH and has not already been deployed, but it does not check thaterc20 != address(0).Bug
Impact:
address(0)slot in_confidentialERC20Mapis permanently poisoned — it cannot be removed.getConfidentialERC20(address(0))returns a non-zero address, creating a potential false-positive in any code that uses zero-address as a sentinel.AlreadyDeployedguard then prevents anyone from attempting to fix it with a second call.Fix
Add
if (address(erc20) == address(0)) revert InvalidERC20();as the first check in the function.