Skip to content
Business logic Audit finding Intermediate

DepositIntoRewardPool and withdrawFromRewardPo

The deposit and withdraw functions in the RewardPoolManager contract call the underlying ERC4626 reward pool without any slippage protection. Because the share-to-asset ratio can move, an attacker front-running the transaction could cause the user to receive fewer shares on deposit or fewer tokens on withdrawal.

kenzo Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

31575 - [SC - Medium] depositIntoRewardPool and withdrawFromRewardPo...

Submitted on May 21st 2024 at 14:08:32 UTC by @Kenzo for Boost | Alchemix

Report ID: #31575

Report type: Smart Contract

Report severity: Medium

Target: https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/RewardPoolManager.sol

Impacts:

  • Contract fails to deliver promised returns, but doesn't lose value
  • Theft of unclaimed yield

Description

Title

depositIntoRewardPool() and withdrawFromRewardPool() in RewardPoolManager are missing slippage control mechanism

Vulnerability Details

The RewardPoolManger is meant to be compatible with ERC4626. The depositIntoRewardPool() and withdrawFromRewardPool() functions are used to deposit and withdraw funds with Aura Pools and the shares and tokens are minted but as it is pool deposit, there is always fluctuations in the ratio deposit to mint or burn to withdraw. The the issue is these two functions don't implement any slippage mechanism to avoid such ratio drop. At worst case, the MEV attacks such as frontrunning the transaction can make loss of shares while depositing and loss of tokens while withdrawing. RewardPoolHandler::depositIntoRewardPool :

Solidity
    function depositIntoRewardPool(uint256 _amount) external returns (bool) {
        require(msg.sender == veALCX, "must be veALCX");

        IERC20(poolToken).approve(rewardPool, _amount);
    
@>      IRewardPool4626(rewardPool).deposit(_amount, address(this));
        return true;
    }
```umm
`RewardPoolHandler::withdrawFromRewardPool` :

```solidity
    function withdrawFromRewardPool(uint256 _amount) external returns (bool) {
        require(msg.sender == veALCX, "must be veALCX");

@>      IRewardPool4626(rewardPool).withdraw(_amount, veALCX, address(this));
        return true;
    }

Impact Details

Users will loss tokens or shares due to not handling the slippage case. At worst, MEV may make user loss a huge amount of funds.

References

https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/RewardPoolManager.sol?utm\\_source=immunefi#L84

https://github.com/alchemix-finance/alchemix-v2-dao/blob/main/src/RewardPoolManager.sol?utm\\_source=immunefi#L93

Recommendation

Implement proper slippage control mechanism in these two functions to avoid the mentioned issue.

Proof of Concept

Attack is straightforward and POC for Mev attacks are hard to simulate.

The original report as published on Immunefi, by Kenzo. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the deposit and withdraw wrappers pass the amount straight to the ERC4626 pool without a minimum-shares or minimum-assets parameter, so the caller cannot bound the exchange rate they accept.

Impact

Users could lose tokens or shares when the ratio shifts, and at worst a front-running MEV attacker could cause a large loss, though the report gives no demonstration of this.

What the attacker needed

Caller must be the veALCX contract; attacker able to front-run the transaction

The fix

Slippage protection should be added to both functions so callers can specify a minimum acceptable amount of shares or tokens.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A reward pool works like a shared pot: you put tokens in and get shares back, and the number of shares you get depends on the pot's current ratio. If someone changes that ratio just before your transaction is processed, you can end up with fewer shares or tokens than you expected. This report says the contract never sets a minimum acceptable amount, so that kind of manipulation is possible.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by kenzo

View all

53 more disclosed reports, best first.

More from Alchemix

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.