Project

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

Missing validation of the values for totalProfit and lastProfit[account].

Summary

The getUnsaved function in the smart contract is designed to calculate the unsaved profit for a specific account based on the difference between totalProfit and lastProfit[account]. However, the function lacks a validation mechanism to ensure that totalProfit is always greater than or equal to lastProfit[account], which could lead to incorrect calculations if totalProfit is smaller than lastProfit[account], resulting in inaccurate results or unintended errors in the system.

Vulnerability Details

The getUnsaved function performs the calculation:

https://github.com/Cyfrin/2024-11-one-world/blob/main/contracts/dao/tokens/MembershipERC1155.sol#L163

return ((totalProfit - lastProfit[account]) * shareOf(account)) / ACCURACY;
  • totalProfit is the total profit calculated for the entire system.

  • lastProfit[account] is the profit that has already been saved for the specific account from the previous update.

However, no checks are performed to verify that totalProfit is not less than lastProfit[account]. If the value of totalProfit is incorrectly altered or erroneous during the calculation process, this could lead to incorrect calculations, for example, resulting in a negative value in the unsaved profit calculation.

Impact

If totalProfit is less than lastProfit[account], the calculation will result in a negative value for the unsaved profit, which will affect the accuracy of the result.

Tools Used

Manual

Recommendations

Add a condition check in the getUnsaved function to ensure that totalProfit is not less than lastProfit[account].

require(totalProfit >= lastProfit[account], "Total profit is less than last profit");
Updates

Lead Judging Commences

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

Support

FAQs

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