Closed sherlock-admin4 closed 6 months ago
1 comment(s) were left on this issue during the judging contest.
panprog commented:
high, dup of #118, incorrect checkpoints amount subtracted during
revokeVestingSchedule
causes permanent inflated amount of user votes.
denzi_
medium
Incorrect Updation of _checkpoints[account] in
ZivoeRewardsVesting::revokeVestingSchedule()
can mess up accounting of votesSummary
The
_checkpoints[account]
inZivoeRewardsVesting::revokeVestingSchedule()
is not updated correctly, which can lead to incorrect accounting of votes.Vulnerability Detail
Vestings are created for a user in
ZivoeRewardsVesting
contract when the ITO callsZivoeRewardsVesting::createVestingSchedule
. At the end of this function, a function call is present :The
_stake
function contains the following block of codeHere we update the
_totalSupplyCheckpoints
and_checkpoints[account]
by theamount
which is to be vested to the account.In
revokeVestingSchedule()
, we have the following codeThe issue is that the code updates
_totalSupplyCheckpoints
and_checkpoints[account]
in the_stake()
with thevestingScheduleOf[account].totalVesting
amount given by the ITO. The totalVesting amount will slowly accrue towards the user as the block.timestamp reaches thevestingScheduleOf[account].end
. So this means theamountWithdrawable()
will only return the totalVesting if block.timestamp has passed vestingScheduleOf[account].end_checkpoints[account] being subtracted by amount which is the so far withdrawable vesting amount causes incorrect accounting of votes. Withdrawable vesting amount will not equal to totalVesting which was initially staked for the user
Proof of Concept
Remove the
onlyZVLOrITO
modifier from createVestingSchedule() and revokeVestingSchedule(). Also remove the require check for credits in createVestingSchedule. Create a new test file in zivoe-core-foundry directory called ZivoeRewardsVesting.t.sol and add the code from the gistProof of Concept
Impact
User will have more voting power than they should, this also messes up the account for
_totalSupplyCheckpoints
. It should never be possible for _checkpoints[account] > _totalSupplyCheckpoints furthermore the User has manipulated voting power which they can use without having anything staked.Code Snippet
createVestingSchedule()
_stake()
[revokeVestingSchedule()][https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/ZivoeRewardsVesting.sol#L429-L467]
Tool used
Manual Review
Recommendation
Change the following line of code in revokeVestingSchedule()
Duplicate of #118