#42527 [SC-Critical] Critical Balance/Supply Desynchronization Leading to Protocol Insolvency and Loss of User Funds
Submitted on Mar 24th 2025 at 14:21:13 UTC by @Invcbull for Audit Comp | Yeet
Report ID: #42527
Report Type: Smart Contract
Report severity: Critical
Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/StakeV2.sol
Impacts:
Protocol insolvency
Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Detail
A critical vulnerability in StakeV2's reward distribution mechanism allows manipulation of accumulatedDeptRewardsYeet() through stake/unstake patterns, leading to protocol insolvency and permanent loss of user funds. The issue creates a "bank run" scenario where early unstakers get paid using other users' funds, ultimately leaving late unstakers with total loss of principal.
Vulnerability Details
Core Issue
function accumulatedDeptRewardsYeet() public view returns (uint256) {
return stakingToken.balanceOf(address(this)) - totalSupply;
}The function fails to account for pending unstakes, creating a desynchronization between balanceOf and totalSupply
Technical Flow Note: I used eth but in this context eth means yeet.
Initial State:
Attack Pattern:
Cascading Insolvency:
In this case we have two victims
Bob : late/last unstaker whose unstake failed due to insufficient contract balance.
Victim : whose stake was incorrectly used as reward due to the contracts failure to account for pending unstakes during accumulatedDeptRewardsYeet()
Impact Details
Protocol Insolvency:
Contract becomes unable to meet staking obligations
Each reward distribution reduces available funds
Creates unsustainable "first to withdraw" scenario
Direct Loss of User Funds:
Late unstakers lose 100% of principal
Not just yield or rewards at risk
Permanent and unrecoverable loss
Systemic Impact:
Affects all stakers in the protocol
Creates bank run incentive
Undermines core protocol functionality
Proof of Concept
Proof of Concept
I included this test function in StakeV2.test.sol
Recommended Mitigation
To fix this issue kindly consider :
Track Pending Unstakes:
Or
Safe Reward Distribution:
Was this helpful?