Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Governor should revert on ERC1155 and ERC721 receive hooks when it's not executor #4307

Closed
ernestognw opened this issue Jun 2, 2023 · 3 comments · Fixed by #4314
Closed
Labels
good first issue Low hanging fruit for new contributors to get involved!

Comments

@ernestognw
Copy link
Member

ernestognw commented Jun 2, 2023

Description

Currently, the Governor implementation uses onERC1155Received, onERC1155BatchReceived, and onERC721Received to acknowledge token receives. However, if the Governor is not the executor itself, it can't operate on those tokens except using the relay function.

We consider that all of these receive hooks can also validate that the Governor is also the executor, as in the receive() function:

/**
 * @dev Function to receive ETH that will be handled by the governor (disabled if executor is a third party contract)
 */
receive() external payable virtual {
    if (_executor() != address(this)) {
        revert GovernorDepositDisabled(address(this));
    }
}
@ernestognw ernestognw changed the title Make Governor.sol to revert on ERC1155 and ERC721 receive hooks if the Governor it's not executor Governor should revert on ERC1155 and ERC721 receive hooks when it's not executor Jun 2, 2023
@ernestognw ernestognw added the good first issue Low hanging fruit for new contributors to get involved! label Jun 2, 2023
@AnmolSirola
Copy link

@ernestognw As it's marked as a good first issue I would like to work on it , could you please provide guidance on how to approach and resolve this issue?
Thank you!

@ernestognw
Copy link
Member Author

Hey @AnmolSirola, thanks for your interest!

Sure, the issue is result from this discussion, we agreed that Governor has no reason to receive tokens if it's no the executor so we're thinking of a check like:

require(address(this) == executor())

We would require also a test for each error to accept the PR, you can instantiate an ERC721 and ERC1155 and use hardhat exposed (already installed in this repo) to call $_safeMint to the governor and trigger the expected error.

Note that the target branch would be master but we're aiming to merge #4261 quite soon.

@clauBv23
Copy link
Contributor

clauBv23 commented Jun 5, 2023

Hi there, I started working on this task before seeing the last comments and opened PR #4314 .

But, after reading the mentioned discussion realized there is an issue and corresponding PR #4284 that proposes to use ERC721Holder & ERC1155Holder instead of the hooks currently defined in Governor, is the expected solution to override ERC721Holder & ERC1155Holder hooks adding the required validation?

Anyway, after merging #4261 and #4284 the PR should be refactored, so not sure if it should be moved to draft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Low hanging fruit for new contributors to get involved!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants