Project

One World
NFTDeFi
15,000 USDC
View results
Submission Details
Severity: high
Invalid

Missing Slot Availability Check in upgradeTier Function

Summary

The upgradeTier function in the provided Solidity code does not check if the target tier still has available slots before minting a new user. This oversight can lead to over-allocation of memberships in a tier, causing potential inconsistencies and errors in the DAO’s membership management.
https://github.com/Cyfrin/2024-11-one-world/blob/main/contracts/dao/MembershipFactory.sol#L155-L160

Vulnerability Details

The vulnerability is due to the absence of a check to ensure that the target tier (fromTierIndex - 1) has available slots before minting a new user. The current code directly mints a new membership without verifying if the tier has reached its maximum capacity:

Without this check, the function can mint new memberships even if the tier is already full, leading to an over-subscription of the tier.

Impact

The lack of validation for available slots in the target tier can result in:

  • Over-allocation of memberships, causing potential financial and operational discrepancies.

  • Users being assigned to tiers that are already full, leading to unfair distribution and possible dissatisfaction among members.

  • Inaccurate tracking of tier capacities, which can affect the overall management and governance of the DAO.

Tools Used

manual review

Recommendations

To fix the issue, add a check to ensure that the target tier has available slots before minting a new user. The updated code should include a validation similar to the following:

function upgradeTier(address daoMembershipAddress, uint256 fromTierIndex) external {
require(daos[daoMembershipAddress].daoType == DAOType.SPONSORED, "Upgrade not allowed.");
++ require(daos[daoMembershipAddress].tiers[fromTierIndex-1].amount > daos[daoMembershipAddress].tiers[fromTierIndex-1].minted, "Tier full.");
require(daos[daoMembershipAddress].noOfTiers >= fromTierIndex + 1, "No higher tier available.");2
IMembershipERC1155(daoMembershipAddress).burn(_msgSender(), fromTierIndex, 2);
IMembershipERC1155(daoMembershipAddress).mint(_msgSender(), fromTierIndex - 1, 1);
emit UserJoinedDAO(_msgSender(), daoMembershipAddress, fromTierIndex - 1);
}
Updates

Lead Judging Commences

0xbrivan2 Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Known issue

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.