Project

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

Overwriting `maxMembers` without proper verification in `MembershipFactory::updateDAOMembership`

Summary

The updateDAOMembership function in the DAO Membership Factory contract includes a flaw that allows the maxMembers limit to be adjusted without validation, leading to an unbounded increase in potential DAO members. This oversight can cause issues in membership management and potentially enable over-minting of memberships beyond the original intent.

Vulnerability Details

In the updateDAOMembership function, the maxMembers limit, which restricts the total number of members a DAO can have, is recalculated based on new tierConfigs input. However, the code does not validate whether the calculated maxMembers aligns with the DAO’s intended capacity or membership limits. This absence of verification can result in an unintended increase in the maxMembers value, allowing additional members beyond the previously set cap.

The following code from updateDAOMembership demonstrates the unchecked adjustment of maxMembers:

https://github.com/Cyfrin/2024-11-one-world/blob/1e872c7ab393c380010a507398d4b4caca1ae32b/contracts/dao/MembershipFactory.sol#L111-L130

uint256 maxMembers = 0;
// Reset and update the tiers array
delete dao.tiers;
for (uint256 i = 0; i < tierConfigs.length; i++) {
dao.tiers.push(tierConfigs[i]);
maxMembers += tierConfigs[i].amount;
}
// updating the ceiling limit acc to new data
if (maxMembers > dao.maxMembers) {
dao.maxMembers = maxMembers;
}
  • maxMembers is recalculated by summing up the amount fields of each tier in tierConfigs.

  • If this new sum exceeds the original dao.maxMembers, the function updates dao.maxMembers to this new value without any validation.

  • This allows for unchecked increases in maxMembers, leading to an expanded membership cap that was not originally intended or authorized.

Let's create a test by updating the tierConfigs with an inflated amount for each tier, thereby bypassing any original membership limits.

function testMaxMembersOverwrite() public {
// Arrange - Deploy a DAO with initial maxMembers set to 30
TierConfig;
initialTiers[0] = TierConfig({amount: 15, minted: 5, price: 1 ether});
initialTiers[1] = TierConfig({amount: 15, minted: 5, price: 2 ether});
address daoAddress = membershipFactory.createNewDAOMembership(
DAOInputConfig({
ensname: "exampleDao",
daoType: DAOType.OPEN,
currency: address(token),
maxMembers: 30,
noOfTiers: 2
}),
initialTiers
);
// Act - Update the DAO to inflate maxMembers by setting larger amounts in new tierConfigs
TierConfig;
newTiers[0] = TierConfig({amount: 50, minted: 5, price: 1 ether});
newTiers[1] = TierConfig({amount: 50, minted: 5, price: 2 ether});
membershipFactory.updateDAOMembership("exampleDao", newTiers);
// Assert - Check if maxMembers was updated beyond the original limit
DAOConfig memory daoConfig = membershipFactory.daos(daoAddress);
require(daoConfig.maxMembers == 100, "Vulnerability confirmed: maxMembers was increased without validation.");
}

Impact

Test show that maxMembers was updated from 30 to 100 due to the increased amount values in the new tierConfigs, confirming that the maxMembers limit was overwritten without checks.

This vulnerability allows administrators or external callers with EXTERNAL_CALLER privileges to increase maxMembers arbitrarily, potentially allowing far more members than the DAO was originally intended to manage.

Expanding the membership cap can place a strain on DAO resources, and the unchecked increase could expose the DAO to unforeseen risks, including dilution of membership value and decision-making integrity.

Tools Used

-

Recommendations

To prevent unauthorized increases in maxMembers, add a validation check to ensure that maxMembers cannot exceed a predefined, immutable limit set during DAO creation. Additionally, explicitly check that maxMembers aligns with any intended or strategic limitations before allowing an increase.

// Ensure maxMembers does not exceed a predefined limit, e.g., initial maxMembers value or configurable limit
require(maxMembers <= daoConfig.originalMaxMembers, "New maxMembers exceeds allowable limit");
Updates

Lead Judging Commences

0xbrivan2 Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

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

Give us feedback!