In a staking pool smart contract, there may exist a flaw in how unused deposits are handled, leading to unclaimed or incorrectly processed deposits. Specifically, when users deposit tokens into the pool, there may be situations where these deposits are either not allocated to strategies correctly or remain unprocessed due to gaps in the logic. This vulnerability may lead to the staking pool being inefficient, with deposits lying idle, or even a loss of funds due to improper handling of those deposits.
The unusedDepositLimit mechanism seems intended to prevent large amounts of tokens from sitting idle in the pool. However, if there is a significant delay between deposits and strategies being deployed, this limit might revert transactions unnecessarily, causing operational issues.
This vulnerability arises when deposits are sent to the staking pool but are not correctly assigned to active strategies or are left in limbo within the contract without being staked. The unused deposits problem is particularly concerning in scenarios where:
The deposit function does not immediately allocate tokens to a strategy.
The logic assumes that all deposits will be distributed among strategies but fails to do so under certain conditions.
There is no mechanism to handle or track these unallocated deposits.
This can result in a significant portion of the user's funds being left idle within the contract, preventing them from earning staking rewards. In some cases, if withdrawals are based on strategy balances alone, these unused deposits may not be retrievable by users.
The following PoC demonstrates how deposits may go unprocessed and lie idle within the staking pool contract.
Realistic attack scenario:
A user deposits tokens into the staking pool.
Due to a flaw in the logic (e.g., a strategy is full, removed, or temporarily unavailable), the tokens remain in the staking pool contract but are not transferred to any active strategy.
The user expects to receive rewards for the deposited tokens but does not, as the tokens were never actually staked.
If the user attempts to withdraw the deposited tokens, the contract may not reflect the correct balance, or in worst cases, these tokens may become unrecoverable.
PoC on Hardhat:
Steps:
Deploy contract: Set up the Staking Pool and two strategies (strategy1 and strategy2).
Deposit: Simulate a user depositing tokens into the pool.
Failure to Assign to Strategy: The pool fails to assign the deposit to any strategy.
Verify Idle Deposit: Check that the deposited tokens remain within the contract but are not staked, leading to unproductive funds.
Tokens that remain unused within the contract do not earn any staking rewards, affecting the user’s expected returns.
If tokens are not correctly tracked, the contract’s internal balances may become inconsistent, leading to potential errors during withdrawals.
Users may become frustrated with the platform due to the lack of rewards on their deposits, leading to a loss of confidence.
In edge cases, if the contract logic does not account for idle deposits correctly, users may lose access to their funds, leading to irreversible losses.
Manual review.
Ensure that deposits are immediately allocated to active strategies. If all strategies are full or unavailable, the transaction should revert, or the contract should clearly handle these edge cases.
Implement a mechanism to track and process idle deposits. Any unassigned funds should either be returned to the user or processed within a reasonable timeframe.
Before allowing a deposit, ensure that there is sufficient capacity in at least one strategy to accommodate the user's tokens.
If strategies are unavailable, the contract should trigger a fallback mechanism, such as holding the tokens in a temporary reserve and notifying the user.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.