Liquid Staking

Stakelink
DeFiHardhatOracle
50,000 USDC
View results
Submission Details
Severity: medium
Invalid

Attackers can deny priority pool from depositing in strategies causing revert always due to front-running

Summary

The StakingPool contract is susceptible to front-running attack in StakingPool::deposit function where there is a condition at a end as mentioned below which causes this attack/issue.This issue arises from a condition at the end of the function, as shown below:

function deposit(
address _account,
uint256 _amount,
bytes[] calldata _data
) external onlyPriorityPool {
require(strategies.length > 0, "Must be > 0 strategies to stake");
uint256 startingBalance = token.balanceOf(address(this));
if (_amount > 0) {
token.safeTransferFrom(msg.sender, address(this), _amount);
_depositLiquidity(_data);
_mint(_account, _amount);
totalStaked += _amount;
} else {
_depositLiquidity(_data);
}
uint256 endingBalance = token.balanceOf(address(this));
@> if (endingBalance > startingBalance && endingBalance > unusedDepositLimit)
revert InvalidDeposit();
}

Vulnerability Details

The Attack is as follows:

  1. Priority pool tries to call this deposit function to transfer funds.

  2. Now attacker observes this in the mempool.

  3. The attacker quickly submits a transaction with a higher gas price, calling StakingPool::donateTokens, which would violate the condition if (endingBalance > startingBalance && endingBalance > unusedDepositLimit) in StakingPool::deposit where at the end this condition is checked for sucessful transaction else it reverts based on the transaction observed in the mempool.

  4. Now due to this the transaction of the PriorityPool calling deposit reverts with this error InvalidDeposit().

Impact

In certain scenarios, priority pool can be prevented from depositing user funds, effectively creating adenial of service condition for the deposit functionality.

Tools Used

Manual Review

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 1 year ago
inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.