Foundation Drop contest - csanuragjain's results

Foundation is a web3 destination.

General Information

Platform: Code4rena

Start Date: 11/08/2022

Pot Size: $40,000 USDC

Total HM: 8

Participants: 108

Period: 4 days

Judge: hickuphh3

Total Solo HM: 2

Id: 152

League: ETH

Foundation

Findings Distribution

Researcher Performance

Rank: 25/108

Findings: 2

Award: $90.99

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

42.8343 USDC - $42.83

Labels

bug
duplicate
2 (Med Risk)

External Links

Lines of code

https://github.com/code-423n4/2022-08-foundation/blob/main/contracts/mixins/nftDropMarket/NFTDropMarketFixedPriceSale.sol#L183

Vulnerability details

Impact

It was observed that any user can bypass saleConfig.limitPerAccount and mint any number of NFT without caring about limitPerAccount. This is happening due to unrestricted transferFrom.

Proof of Concept

  1. User A has minted say 10 NFT and saleConfig.limitPerAccount is also 10

  2. Now User A calls mintFromFixedPriceSale and try to mint 10 more NFT

  3. The below condition fails since user has already reached threshold of saleConfig.limitPerAccount

if (IERC721(nftContract).balanceOf(msg.sender) + count > saleConfig.limitPerAccount) { if (saleConfig.limitPerAccount == 0) { // Provide a more targeted error if the collection has not been listed. revert NFTDropMarketFixedPriceSale_Must_Have_Sale_In_Progress(); } revert NFTDropMarketFixedPriceSale_Cannot_Buy_More_Than_Limit(saleConfig.limitPerAccount); }
  1. User A simply use transferFrom function at NFTDropCollection.sol to transfer 10 NFT to his another owned address (Contract implements ERC721Upgradeable which allows transferFrom)

  2. Now User A new balance becomes 0 and he can simply mint NFT using Step 2

  3. Once User A has minted 10 NFT, he again uses transferFrom to transfer back his NFT from his another owned address to his own adddress. This means User A has now 20 NFT even though limit per account was set as 10

  4. This way using 2 address any user can simply bypass saleConfig.limitPerAccount

Override the transferFrom/safeTransferFrom function (or beforetokenTransfer) and check if post transfer balanceOf(msg.sender)+amount <=saleConfig.limitPerAccount, if not revert

#0 - HardlyDifficult

2022-08-17T20:56:38Z

Token Id existence not checked

Contract: https://github.com/code-423n4/2022-08-foundation/blob/main/contracts/NFTCollection.sol#L298

Issue: In getTokenCreatorPaymentAddress function, It is not checked whether tokenId actually exists. Even if it does not exist creatorPaymentAddress will be returned as owner. This seem to be used by CollectionRoyalties.sol to calculate Royalties, fees. CollectionRoyalties seem to be exposing API which means that this will give incorrect data.

Recommendation: Revise the function to include below checks:

require(_exists(tokenId), "NFTCollection: URI query for nonexistent token");

Unused function

Contract: https://github.com/code-423n4/2022-08-foundation/blob/main/contracts/NFTDropCollection.sol#L245

Issue: _burn: This function is marked internal and does not seem to be used.

Recommendation: Remove the function if not required

#0 - HardlyDifficult

2022-08-18T19:29:11Z

Token Id existence not checked

This is a fair point, we will consider adding that check.

Unused function

Invalid. This was required due to a compile error from the inheritance used here.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter