57924 sc critical the staking contract is suceptible to the classic first depositor exploit

Submitted on Oct 29th 2025 at 13:37:26 UTC by @TheWeb3Mechanic for Audit Comp | Belongarrow-up-right

  • Report ID: #57924

  • Report Type: Smart Contract

  • Report severity: Critical

  • Target: https://github.com/immunefi-team/audit-comp-belong/blob/main/contracts/v2/periphery/Staking.sol

triangle-exclamation

Impacts

  • Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield

Description

Brief / Intro

The staking contract inherits the solady implementation of ERC4626. However, the virtual offset that was put in place to ensure that users are protected from losses due to inflation was never set to a non-zero value. Hence the inflation vector still exists.

Vulnerability Details

The inflation vector is currently present because:

  • virtual offset is currently unset

  • The totalAsset used in share calculation depends directly on contract balance

  • There is no revert when users get minted 0 shares

Attack outline:

  1. Attacker deposits 1 wei of LONG token via Staking::deposit and gets minted 1 wei share token (becomes the only shareholder).

  2. Attacker directly transfers additional tokens into the contract (not via deposit), inflating totalAssets.

  3. A subsequent legitimate depositor calls deposit and, due to rounding, receives 0 shares while their assets end up in the contract.

  4. Attacker (owning the only share) back-runs or simply calls withdraw and claims almost the entire contract balance.

Relevant vulnerable line in the solady-derived code:

The highlighted return computes shares as assets * (totalSupply + 1) / _inc(totalAssets). When totalAssets is large relative to assets * (totalSupply + 1), this division can round down to 0. Because the contract does not revert when 0 shares are minted, the depositor loses their tokens to the vault while receiving 0 shares. The attacker can then withdraw all funds since they control the only shares.

Impact Details

  • Loss of funds for depositors who receive 0 shares (their tokens become unrecoverable by them and can be withdrawn by the attacker who holds shares).

References

https://github.com/immunefi-team/audit-comp-belong/blob/a17f775dcc4c125704ce85d4e18b744daece65af/contracts/v2/periphery/Staking.sol#L242

Proof of Concept

chevron-rightFoundry test reproducing the exploit (expand to view)hashtag

Was this helpful?