57482 sc critical front running a donation can inflate the share causing users to lose funds

Submitted on Oct 26th 2025 at 15:38:40 UTC by @ox9527 for Audit Comp | Belongarrow-up-right

  • Report ID: #57482

  • Report Type: Smart Contract

  • Report severity: Critical

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

  • Impacts:

    • Permanent freezing of funds

triangle-exclamation

Description

Brief / Intro

In Staking.sol::deposit(), a minimum deposit amount is enforced. An attacker can front-run by depositing just 1 wei into the staking contract and then transferring additional LONG tokens directly to it.

This manipulates the share calculation, leading to share inflation, which causes subsequent users to receive zero shares for their deposits and ultimately suffer a loss of funds.

Vulnerability Details

In Staking.sol::deposit() the contract calls:

function _deposit(address by, address to, uint256 assets, uint256 shares) internal override {
    super._deposit(by, to, assets, shares); <@
    // lock freshly minted shares
    stakes[to].push(Stake({shares: shares, timestamp: block.timestamp})); 
}

The sequence allows an attacker to create a situation where the contract's token balance increases (via direct token transfer / "donation") after a minimal deposit, inflating the assets-versus-shares ratio and causing following deposits to mint zero shares.

Impact Details

  • Subsequent users can receive zero shares for their deposits.

  • Funds may become effectively frozen or lost for honest users who can no longer obtain shares proportional to their deposits.

Exploit steps

1

Step: Attacker makes a minimal deposit

Attacker deposits the minimum enforced amount (e.g., 1 wei) via deposit() so they receive shares.

2

Step: Attacker donates additional tokens directly

Attacker transfers additional LONG tokens directly to the staking contract (not via deposit()), increasing the contract's token balance without minting shares.

3

Step: Share calculation is skewed

Because the contract's asset balance increases while total shares remain nearly unchanged, the assets-per-share ratio inflates. Subsequent deposit calls compute shares using the new (inflated) ratio and may mint zero shares for honest users.

Proof of Concept

chevron-rightSolidity Forge test PoC (expand to view)hashtag

References

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

(End of report)

Was this helpful?