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

Use safeMint for ERC721 #445

Closed
code423n4 opened this issue Sep 15, 2022 · 2 comments
Closed

Use safeMint for ERC721 #445

code423n4 opened this issue Sep 15, 2022 · 2 comments
Labels
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 invalid This doesn't seem right 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-09-nouns-builder/blob/main/src/auction/Auction.sol#L206

Vulnerability details

🎨 Category

ERC721, Data Validation

💥 Impact

In Auction.sol, the _createAuction() function eventually calls mint() in Token.sol.

https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/token/Token.sol#L143

Calling mint this way does not ensure that the settings.auction can handle ERC721 properly.

📝 Proof of Concept

https://github.com/code-423n4/2022-09-nouns-builder/blob/main/src/auction/Auction.sol#L206

🚜 Tools Used

Manual

✅ Recommended Mitigation Steps

Use _safeMint() function of Opnezeppelin instead of the mint function.
And this function should be used with reentrancy guards as a guard to protect the user.

https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC721/ERC721.sol

function _safeMint(address to, uint256 tokenId) internal virtual {
     _safeMint(to, tokenId, "");
 }
function _safeMint(
    address to,
    uint256 tokenId,
    bytes memory data
) internal virtual {
    _mint(to, tokenId);
    require(
        _checkOnERC721Received(address(0), to, tokenId, data),
        "ERC721: transfer to non ERC721Receiver implementer"
    );
}

👬 Similar Issue

code-423n4/2022-01-sandclock-findings#29

@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 Sep 15, 2022
code423n4 added a commit that referenced this issue Sep 15, 2022
@GalloDaSballo
Copy link
Collaborator

I believe that adding this check can be used for DOS and probably will cause more issues than it solves.

I also would find it very odd for a caller to bid on an NFT they can't move

@GalloDaSballo
Copy link
Collaborator

GalloDaSballo commented Sep 26, 2022

After further consideration, I believe this design decision was made on purpose, any msg.sender that decides to interact with the protocol is expected to be able to receive the tokens they are bidding for.

Not being able to do that is equivalent to them transferring the tokens to the address(0) (or delegating to 0, per other reports from this contest)

Meaning is completely within the decision of the bidder.

Allowing to revert on mint creates more problems than necessary, adds further complexity, increase gas cost and increases the surface area.

Because I believe the Sponsor has gone through these ideas, I belive the finding to be invalid

I'd recommend the sponsor to warn users about being able to move tokens they are buying for, however at this time am choosing those close these reports as invalid as I don't think the implementation is expected, and the reference example of Nouns Dao has been working this way for over a year

@GalloDaSballo GalloDaSballo added the invalid This doesn't seem right label Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 invalid This doesn't seem right sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

2 participants