Closed sherlock-admin2 closed 6 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid
The protocol team fixed this issue in PR/commit https://github.com/dhedge/flatcoin-v1/pull/269.
I believe this is invalid based on the following sherlock rule.
An admin action can break certain assumptions about the functioning of the code. Example: Pausing a collateral causes some users to be unfairly liquidated or any other action causing loss of funds. This is not considered a valid issue.
ydlee
high
User's FMPs may get locked forever when
unlockTaxVest
gets decreased.Summary
Owner can change
unlockTaxVest
, which can affect the calculation ofunlockTax
. However the unlock tax calculation system does not work well in such situation, and may cause user's FMP to be locked in the contract forever.Vulnerability Detail
When minting FMPs for a user, the FMPs are locked for a period of time as vesting period (namely
unlockTaxVest
). The unlock time is calculated asblock.timestamp + unlockTaxVest
(To make it simple, we assume that the user has not own FMP before).https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/PointsModule.sol#L142-L155
If the user wants to unlock his FMPs before the unlocking time, some of his FMPs are transfered to treasury as
unlockTax
. TheunlockTax
is calculated as(unlockingTime - block.timestamp) / unlockTaxVest
. Notice thatunlockingTime
is set during minting and will not change thereafter (without new mints for the user), butunlockTaxVest
may change if owner changes it. This may lead to unexpectedunlockTax
.https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/PointsModule.sol#L120-L128
POC:
unlockTaxVest
is 12 months.unlockTaxVest
to 5 months.unlock
her FMPs, theunlockTax
is first calculated as(12 months - 6 months) / 5 months = 1.2e18
, which will revert asassert(unlockTax <= 1e18)
(L127). Alice will not be able to unlock her FMP.Impact
User's FMP get locked in the contract forever due to descresed
unlockTaxVest
.Code Snippet
https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/PointsModule.sol#L142-L155
https://github.com/sherlock-audit/2023-12-flatmoney/blob/main/flatcoin-v1/src/PointsModule.sol#L120-L128
Tool used
Manual Review
Recommendation
Save the
unlockTaxVest
withunlockTime
for every user at minting time, and use it instead of theunlockTaxVest
state variable to calculate theunlockTax
. Remember to update user'sunlockTaxVest
when new minting'sunlockTaxVest
is different from the saved one.