57809 sc critical inflation of shares in staking contract

Submitted on Oct 29th 2025 at 01:16:27 UTC by @siddhu for Audit Comp | Belongarrow-up-right

  • Report ID: #57809

  • Report Type: Smart Contract

  • Report severity: Critical

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

  • Impacts:

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

Description

Brief/Intro

A critical cross-contract vulnerability exists between BelongCheckIn.sol and Staking.sol that enables malicious venues to execute devastating first-depositor inflation attacks. This vulnerability allows malicious venues to exploit their legitimate access to LONG tokens (received through protocol operations) to manipulate the Staking contract's share price by directly transferring assets, resulting in complete loss of funds for subsequent depositors. The attack leverages the interaction between BelongCheckIn functional mechanisms like payToVenue and ERC4626 staking implementation flaws.

Vulnerability Details

Cross-Contract Attack Vector

This vulnerability exploits the interaction between two protocol components:

BelongCheckIn Contract: Venues receive LONG tokens through legitimate customer payment operations:

Staking Contract: Vulnerable to first-depositor inflation attacks due to ERC4626 implementation flaws.

Attack Sequence

1

LONG Token Accumulation

Malicious venue sets longPaymentType = LongPaymentTypes.Direct and receives LONG tokens directly from customer payments through the payToVenue function.

2

First Depositor Advantage

Venue monitors Staking contract deployment and becomes the first depositor with minimal amount (1 wei).

3

Share Price Manipulation

Venue directly transfers accumulated LONG tokens to Staking contract, artificially inflating totalAssets() without minting shares.

4

Victim Exploitation

Innocent users deposit LONG tokens and receive disproportionately few shares due to inflated exchange rate.

5

Complete Fund Theft / Inflated Amount

Due to rounding behavior, victims can receive 0 shares for their deposits or receive far fewer shares than the value deposited.

Formula: shares = assets × totalShares ÷ totalAssets and assets = shares × totalAssets ÷ totalShares

Impact Details

Victims receive fewer shares for the same deposit amount because the asset-to-share exchange rate has been artificially inflated by direct transfers to the vault, enabling attackers to extract value for minimal deposits.

References

  • Vulnerable Contract: src/periphery/Staking.sol

  • Test Case: test/Staking.t.sol::testFirstDepositorInflationAttack()

  • ERC4626 Standard: EIP-4626arrow-up-right

  • Enforce substantial minimum deposits to make attacks economically unfeasible.

  • Implement safeguards against direct asset transfers that bypass share minting (e.g., reject plain ERC20 transfers, account for token transfers in totalAssets calculations, or implement an onERC20Received hook that mints corresponding shares).

  • Consider handling unexpected token transfers by reconciling balances and minting shares to the protocol or a designated address, or by rejecting transfers entirely.

Proof of Concept

Actual test results show:

  • Attacker deposits 1 wei → receives 1 share

  • Attacker directly transfers LONG → inflates totalAssets

  • Victim deposits LONG → receives far fewer shares (or 0 shares)

  • Both shares worth different LONG each, attacker benefits massively

PoC test contract:

Was this helpful?