#42518 [SC-Critical] Incorrect handling of total staked funds will lead to protocol insolvency
Description
Brief/Intro
Vulnerability Details
function startUnstake(uint256 unStakeAmount) external {
require(unStakeAmount > 0, "Amount must be greater than 0");
require(stakedTimes[msg.sender] < STAKING_LIMIT, "Amount must be less then the STAKING_LIMIT constant"); // DOS protection https://github.com/Enigma-Dark/Yeet/issues/12
_updateRewards(msg.sender);
uint256 amount = balanceOf[msg.sender];
require(amount >= unStakeAmount, "Insufficient balance");
balanceOf[msg.sender] -= unStakeAmount;
@> totalSupply -= unStakeAmount;
uint256 start = block.timestamp;
uint256 end = start + VESTING_PERIOD;
vestings[msg.sender].push(Vesting(unStakeAmount, start, end));
stakedTimes[msg.sender]++;
emit VestingStarted(msg.sender, unStakeAmount, vestings[msg.sender].length - 1);
}Impact
Proof of Concept
Proof of Concept
Previous#42469 [SC-Critical] Incorrect computation of excess rewards leads to permanent freezing of user fundsNext#42525 [SC-High] Misallocation of leftover token1 in StakeV2.claimRewardsInToken0
Was this helpful?