57786 sc high malicious users can frontrun staking distributerewards to claim majority of rewards

Submitted on Oct 28th 2025 at 21:15:40 UTC by @Josh4324 for Audit Comp | Belongarrow-up-right

  • Report ID: #57786

  • Report Type: Smart Contract

  • Report severity: High

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

  • Impacts:

    • Theft of unclaimed yield

Description

Brief / Intro

The Staking contract's distributeRewards function is vulnerable to a frontrunning attack. A malicious user with access to large deposits can monitor the mempool for pending reward distributions, frontrun by depositing a substantial amount of LONG tokens to mint shares at the pre-reward rate, and then capture a disproportionate share of the rewards upon distribution.

This dilutes rewards for existing stakers and allows the attacker to profit by withdrawing post-rebase. The issue arises from the lack of protections against sudden share inflation before rewards.

Vulnerability Details

The vulnerable function:

function distributeRewards(uint256 amount) external onlyOwner {
    if (amount == 0) revert ZeroReward();
    LONG.safeTransferFrom(msg.sender, address(this), amount);
    emit RewardsDistributed(amount);
}

distributeRewards(uint256 amount) adds rewards by transferring LONG into the vault, increasing totalAssets() without minting new shares, which rebases the asset-per-share rate upward for existing holders.

There is no protection against frontrunning: an attacker can deposit a large amount just before the reward tx confirms, minting shares at the lower pre-reward rate, and then benefit from the rebase on their inflated share count. Upon withdrawal, the attacker realizes gains proportional to their temporary dominance in total shares, effectively stealing from legitimate stakers.

Attack Vector

1

Monitor mempool

Observe a pending distributeRewards transaction in the mempool.

2

Frontrun with deposit

Frontrun by depositing a large amount of LONG to the staking contract, minting shares at the pre-reward rate.

3

Let rewards rebase

Allow the reward transaction to execute, increasing assets in the vault without minting shares, which increases the asset-per-share value.

4

Withdraw amplified assets

Redeem shares after the rebase to capture a disproportionate amount of the distributed rewards.

Conditions for Exploitation

  • Pending distributeRewards tx visible in mempool.

  • Attacker has access to large LONG liquidity (e.g., flash loans).

  • Attacker may have to wait minStakePeriod if required, but profit can still exceed delay.

Impact Details

triangle-exclamation

References

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

Proof of Concept

Run the provided test in test/v2/platform/file.test.ts. Example test (Hardhat):

To run:

yarn test test/v2/platform/file.test.ts

chevron-rightTest output (example)hashtag

Was this helpful?