Skip to content
Business logic Audit finding Intermediate

Lack of Slippage Control in AuraVault::deposit and AuraVault::mint Functions Can Lead to Unexpected Financial Losses for Users

The AuraVault contract's deposit and mint functions lack slippage controls, so users cannot specify a minimum number of shares or a maximum amount of assets. An attacker could exploit this by manipulating the share price, causing users to receive fewer shares or pay more assets than expected.

Agontuk Follow with Bauchibred, minglei-wang-3570 and 1 other

Originally disclosed on Code4rena

Submitted by Agontuk, also found by Bauchibred, minglei-wang-3570, and crypticdefense

The AuraVault contract implements ERC-4626 vault functionality, allowing users to deposit assets and mint shares. However, the deposit and mint functions lack slippage controls, which can result in users receiving fewer shares or sending more assets than expected. This issue is similar to a previously reported bug in the bHermes contract, where the absence of slippage controls in the ERC4626DepositOnly.deposit and ERC4626DepositOnly.mint functions led to unexpected outcomes for users.

Detailed Description

The AuraVault contract is designed to manage assets and distribute rewards from an Aura RewardsPool. It includes functions for depositing assets and minting shares, which are critical for users interacting with the vault. However, these functions do not allow users to specify slippage parameters, exposing them to potential financial losses.

deposit Function

The deposit function allows users to deposit a specified amount of assets and receive shares in return. The function calculates the number of shares to be minted using the previewDeposit function and then proceeds with the deposit. However, it does not allow users to specify a minimum number of shares to be minted, which can lead to slippage issues.

File: AuraVault.sol
199:     function deposit(uint256 assets, address receiver) public virtual override(IERC4626, ERC4626) returns (uint256) {
200:         uint256 shares = previewDeposit(assets);
201:         _deposit(_msgSender(), receiver, assets, shares);
202:
203:         // Deposit  in reward pool
204:         IERC20(asset()).safeApprove(rewardPool, assets);
205:         IPool(rewardPool).deposit(assets, address(this));
206:
207:         return shares;
208:     }

mint Function

The mint function allows users to mint a specified number of shares by depositing the required amount of assets. The function calculates the required assets using the previewMint function and then proceeds with the minting. However, it does not allow users to specify a maximum number of assets to be sent, which can lead to slippage issues.

File: AuraVault.sol
216:     function mint(uint256 shares, address receiver) public virtual override(IERC4626, ERC4626) returns (uint256) {
217:         uint256 assets = previewMint(shares);
218:         _deposit(_msgSender(), receiver, assets, shares);
219:
220:         // Deposit assets in reward pool
221:         IERC20(asset()).safeApprove(rewardPool, assets);
222:         IPool(rewardPool).deposit(assets, address(this));
223:
224:         return assets;
225:     }

Root Cause

The root cause of the issue is the absence of slippage control parameters in the deposit and mint functions. Users cannot specify minimum shares to be minted or maximum assets to be sent, leading to potential financial losses due to slippage.

Impact

Users can lose funds due to unexpected slippage when interacting with the AuraVault contract. Specifically, they may receive fewer shares than expected when depositing assets or send more assets than expected when minting shares. This can result in significant financial losses, especially in volatile market conditions.

Proof of Concept

  1. Alice wants to deposit 1000 units of an asset into the AuraVault contract and expects to receive at least 100 shares.
  2. Alice calls the deposit function with 1000 units of the asset.
  3. Due to slippage, Alice receives only 90 shares instead of the expected 100 shares.
  4. Alice loses value because she received fewer shares than expected.

Similarly, for the mint function:

  1. Bob wants to mint 100 shares and expects to send no more than 1000 units of the asset.
  2. Bob calls the mint function with 100 shares as the input.
  3. Due to slippage, Bob ends up sending 1200 units of the asset instead of the expected 1000 units.
  4. Bob loses value because he sent more assets than expected.

Recommended Mitigation Steps

Add slippage control parameters to the deposit and mint functions to allow users to specify minimum shares to be minted and maximum assets to be sent. This will ensure that transactions revert if the slippage conditions are not met.

- function deposit(uint256 assets, address receiver) public virtual override(IERC4626, ERC4626) returns (uint256) {
+ function deposit(uint256 assets, uint256 minShares, address receiver) public virtual override(IERC4626, ERC4626) returns (uint256) {
    uint256 shares = previewDeposit(assets);
+   require(shares >= minShares, "AuraVault: Insufficient shares minted");
    _deposit(_msgSender(), receiver, assets, shares);

    // Deposit in reward pool
    IERC20(asset()).safeApprove(rewardPool, assets);
    IPool(rewardPool).deposit(assets, address(this));

    return shares;
}

- function mint(uint256 shares, address receiver) public virtual override(IERC4626, ERC4626) returns (uint256) {
+ function mint(uint256 shares, uint256 maxAssets, address receiver) public virtual override(IERC4626, ERC4626) returns (uint256) {
    uint256 assets = previewMint(shares);
+   require(assets <= maxAssets, "AuraVault: Excessive assets required");
    _deposit(_msgSender(), receiver, assets, shares);

    // Deposit assets in reward pool
    IERC20(asset()).safeApprove(rewardPool, assets);
    IPool(rewardPool).deposit(assets, address(this));

    return assets;
}

These changes allow users to specify their slippage tolerance, protecting them from unexpected losses due to market volatility or delayed transaction execution.

amarcu (LoopFi) acknowledged and commented:

Acknowledged, but we will remove and not use the AuraVault.

Koolex (judge) commented:

EIP4626 encourage to add slippage protection by adding additional functions which doesn’t violate it.

If implementors intend to support EOA account access directly, they should consider adding an additional function call for deposit/mint/withdraw/redeem with the means to accommodate slippage loss or unexpected deposit/withdrawal limits, since they have no other means to revert the transaction if the exact output amount is not achieved.

Note: For full discussion, see here.


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

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

The deposit and mint functions do not accept parameters for minimum shares or maximum assets, so users have no protection against slippage.

Impact

Users could lose funds due to slippage, receiving fewer shares or sending more assets than expected, especially in volatile markets.

What the attacker needed

User interacts with AuraVault deposit or mint; Market conditions cause slippage

The fix

The deposit and mint functions should be modified to accept a minimum shares parameter and a maximum assets parameter, respectively, and revert if the conditions are not met.

How it was found

  1. Alice wants to deposit 1000 units of an asset and expects at least 100 shares.
  2. Alice calls the deposit function with 1000 units.
  3. Due to slippage, Alice receives only 90 shares instead of 100.
  4. Alice loses value because she received fewer shares than expected.

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.

When you put money into a vault, you get shares in return. The number of shares you get depends on the vault's current value, which can change quickly. Without a way to say 'I want at least this many shares' or 'I won't pay more than this much', you might get a bad deal if the value changes between when you click and when the transaction completes.

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 Agontuk

View all

3 more disclosed reports, best first.

More from LoopFi

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.