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

Implement and use _safeMint rather than _mint #462

Closed
Tracked by #88
code423n4 opened this issue Oct 25, 2022 · 4 comments
Closed
Tracked by #88

Implement and use _safeMint rather than _mint #462

code423n4 opened this issue Oct 25, 2022 · 4 comments
Labels
bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax responded The Holograph team has reviewed and responded sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-10-holograph/blob/f8c2eae866280a1acfdc8a8352401ed031be1373/contracts/enforcer/HolographERC721.sol#L814-L822
https://github.com/code-423n4/2022-10-holograph/blob/f8c2eae866280a1acfdc8a8352401ed031be1373/contracts/enforcer/HolographERC721.sol#L399-L411
https://github.com/code-423n4/2022-10-holograph/blob/f8c2eae866280a1acfdc8a8352401ed031be1373/contracts/enforcer/HolographERC721.sol#L508-L515

Vulnerability details

Impact

The custom implementation of a ERC721 it's not implement the function _safeMint
For example: The safeTransferFrom send and check the onERC721Received fallback

Proof of Concept

If the beneficiary of the mint it's a contract this asset could be stuck on it, if the contract not be prepare to receive assets

Tools Used

Review

Recommended Mitigation Steps

Implement the function _safeMint and use it like in OZ contracts

Note: be careful with the possible reentrancy attacks

@code423n4 code423n4 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Oct 25, 2022
code423n4 added a commit that referenced this issue Oct 25, 2022
@gzeoneth gzeoneth added the disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) label Oct 30, 2022
@alexanderattar alexanderattar added sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue responded The Holograph team has reviewed and responded labels Nov 8, 2022
@alexanderattar
Copy link

_safeMint is not required here

@rotcivegaf
Copy link

What happens if the beneficiary of the mint it's a contract who not be prepared to receive assets?
Or if the beneficiary expects the _checkOnERC721Received callback?

@alexanderattar
Copy link

The problem is that _safeMint opens up a security loophole where the receiving contract can introduce unexpected gas usages, malicious code, and reentrancy. Since mint is used in conjunction with bridge requests, this is a critical code path, and the costs of introducing potential attack vectors outweighs the concern of user error by minting to a contract that is not prepared to handle erc721 tokens.

References:

https://blocksecteam.medium.com/when-safemint-becomes-unsafe-lessons-from-the-hypebears-security-incident-2965209bda2a

https://samczsun.com/the-dangers-of-surprising-code/

@gzeoneth gzeoneth added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Nov 19, 2022
@gzeoneth
Copy link
Member

Consider with #422

@gzeoneth gzeoneth added the duplicate This issue or pull request already exists label Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working disagree with severity Sponsor confirms validity, but disagrees with warden’s risk assessment (sponsor explain in comments) duplicate This issue or pull request already exists QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax responded The Holograph team has reviewed and responded sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

4 participants