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
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.
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.
manual review
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:
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.