#41289 [SC-Critical] StakeV2 Contract Insolvency Issue

Submitted on Mar 13th 2025 at 10:59:06 UTC by @rajkaur for Audit Comp | Yeet

  • Report ID: #41289

  • Report Type: Smart Contract

  • Report severity: Critical

  • Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/StakeV2.sol

  • Impacts:

    • Protocol insolvency

Description

Brief/Intro

During unstaking, totalSupply immediately decreases, but tokens remain in the contract, resulting in incorrect rewards. Users can claim these as "rewards," making the contract insolvent and preventing some users from withdrawing funds.

Vulnerability Details

The main issue is in how contract calculate rewards. Look at this function: When user call startUnstake(), the function reduce totalSupply but tokens still in contract:

function accumulatedDeptRewardsYeet() public view returns (uint256) {
    return token.balanceOf(address(this)) - totalSupply;
}

This create big problem because contract think it has extra tokens (rewards) but actually these token are owed to users who are unstaking. Then manager can call executeRewardDistributionYeet() and take these "rewards" out of contract.

##POC

Initial state: Contract balance: 100 tokens Total supply: 100 tokens Accumulated rewards: 0 tokens

After 8 users start unstaking: Contract balance: 100 tokens Total supply: 20 tokens Accumulated rewards: 80 tokens

After distributing rewards: Contract balance: 40 tokens Total supply: 20 tokens Accumulated rewards: 20 tokens

User 0 unstaked successfully User 1 unstaked successfully User 2 unstaked successfully User 3 unstaked successfully

Proof of Concept

Proof of Concept

Was this helpful?