#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.

  1. Initial State:

  1. Attack Pattern:

  1. Cascading Insolvency:

In this case we have two victims

  1. Bob : late/last unstaker whose unstake failed due to insufficient contract balance.

  2. Victim : whose stake was incorrectly used as reward due to the contracts failure to account for pending unstakes during accumulatedDeptRewardsYeet()

Impact Details

  • Protocol Insolvency:

  1. Contract becomes unable to meet staking obligations

  2. Each reward distribution reduces available funds

  3. Creates unsustainable "first to withdraw" scenario

  • Direct Loss of User Funds:

  1. Late unstakers lose 100% of principal

  2. Not just yield or rewards at risk

  3. Permanent and unrecoverable loss

  • Systemic Impact:

  1. Affects all stakers in the protocol

  2. Creates bank run incentive

  3. Undermines core protocol functionality

Proof of Concept

Proof of Concept

I included this test function in StakeV2.test.sol

To fix this issue kindly consider :

  1. Track Pending Unstakes:

Or

  1. Safe Reward Distribution:

Was this helpful?