The upgradeTier
function in the MembershipFactory
contract allows users to upgrade their membership tier by burning NFTs from a lower tier and minting NFTs for a higher tier. However, the function does not check if the higher tier has already been fully minted. This oversight allows users to bypass the minting limit and mint NFTs for a tier that is already fully minted, leading to inconsistencies in the NFT distribution and potential financial losses for users.
MembershipFactory.sol#L155-L161
when calling upgradeTier
, there are no checks whether the fromTierIndex - 1
that already minted is less than amount specified. this would makes anyone can bypass to upgrade to the next tier even though the next tier is minted out.
scenario:
create DAO with SPONSORED type, the amount max minted is 2
bob joins DAO on tierIndex 1 with 2 nft (this would minted out the tierIndex 1 nft)
charlie wants to join tierIndex 1 too, but saw its minted out
charlie joins DAO using tierIndex 2 with 2 nft
charlie call upgradeTier
now charlie have tierIndex 1 nft
add this code to test
folder:
ERC20Mock.sol
:
Base.t.sol
:
run the command forge test --mt test_POC_upgradeTierBypassMintedCheck
the test would fail because assert failed.
Minting an already minted-out NFT tier would break many invariants, causing significant disruptions in the system. This could lead to inconsistencies in the NFT distribution, potential financial losses for users, and a loss of trust in the platform's reliability. Ensuring that minting operations respect the tier limits is crucial to maintaining the integrity and stability of the NFT ecosystem.
foundry
add logic to check if the next tier is still available to be minted:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.