Project

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

`MembershipERC1155` profit tokens can be drained due to Unmatched ids and amounts arrays in `_update` when minting and claiming profit

Summary

When MembershipERC1155:claimProfit is called by a DAO member, the _update function is implemented to keep track of their claimed rewards; however , there is a potential issue with ids and amounts Arrays when minting/burning membership tokens or when transferring membership tokens to a new account.

The _update function takes two arrays, ids and amounts, which represent the token IDs and corresponding amounts being transferred. However, there is no check to ensure that the ids and amounts arrays have matching lengths. If the arrays have different lengths, it could lead to out-of-bounds access or incorrect handling of token transfers.

Hence, when minting or transferring, a new user will be considered eligible for a share of previous profit from before they were a DAO member. Aside from the obvious case where a new DAO member claims profits at the expense of other existing members, this can be weaponized by recycling the same membership token between fresh accounts and claiming until the profit token balance of the MembershipERC1155Contract has been drained.

Vulnerability Details

https://github.com/Cyfrin/2024-11-one-world/blob/1e872c7ab393c380010a507398d4b4caca1ae32b/contracts/dao/tokens/MembershipERC1155.sol#L203

Impact

DAO members can claim profits to which they should not be entitled and malicious users can drain the MembershipERC1155 contract of all profit tokens (including those from membership fees if paid in the same currency)

Tools Used

Manual Review

Recommendations

Add a check to verify that the ids and amounts arrays are of equal length:

require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");

Here is an improved code

function \_update(\
address from,\
address to,\
uint256\[] memory ids,\
uint256\[] memory amounts\
) internal virtual override(ERC1155Upgradeable) {\
// Check if arrays are of equal length\
require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch");
// Save profit for sender and receiver, if not address(0)
if (from != address(0)) {
saveProfit(from);
}
if (to != address(0)) {
saveProfit(to);
}
// Call the parent function to handle actual token transfer logic
super._update(from, to, ids, amounts);
}
Updates

Lead Judging Commences

0xbrivan2 Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
0xbrivan2 Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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