The upgradeTier function in the DAO contract allows users to upgrade their membership tier by burning tokens from the current tier and minting a single token in a higher-share tier (lower index). However, the function lacks a check to ensure that the tier upgrade process does not result in a loss to the protocol. When a user upgrades to a tier with a higher price, the protocol does not require additional payment, leading to a discrepancy in funds and a potential financial loss.
The vulnerability arises because the upgradeTier function does not verify if the price of the target tier (lower index) is higher than the price of the current tier. Without this verification, a user could upgrade to a more valuable tier without paying the difference, causing a direct loss to the protocol.
This vulnerability can lead to financial losses for the protocol as users can bypass the actual cost of higher-priced tiers during the upgrade process. This loss occurs because the function mints a token for a higher-share tier without charging the user appropriately, thus creating a potential exploit for savvy users.
The price of Tier 2 is 10e6.
The price of Tier 1 is 50e6.
Alice joined the DAO membership at Tier 2 twice, paying a total of 20e6.
Now, Alice calls upgradeTier for Tier 2.
There is a significant price difference between Tier 2 and Tier 1.
However, in upgradeTier, there is no check to verify if the price of Tier 1 is higher.
This means that Alice can obtain more shares by paying far less than the actual Tier 1 price.
Create a BugTest.t.sol contract in the test folder.
Add the following code to the BugTest.t.sol file:
Run the test using the command forge test --mt test_FortisAudit_Loss_Of_Funds_In_UpgradeTier -vvvv.
Foundry
To mitigate this issue, add a check in the upgradeTier function to ensure that the user covers any price difference when moving to a higher-cost tier. Specifically:
Retrieve the prices of the current tier and the target tier.
If the target tier's price is higher, require the user to pay the difference before executing the upgrade.
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.