Skip to content
Business logic Audit finding Intermediate

minimumPull Vault parameter cannot be adjusted

The minimumPull parameter in the Vault contract is hardcoded to 10^6 and cannot be changed, which can block withdrawals when the vault token has low decimals and high value. An attacker could not directly exploit this, but it can cause legitimate withdrawals to be frozen.

hyh Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-01-derby-judging/issues/154

Found by

hyh

Summary

minimumPull is hardcoded to be 10^6 in Vault and can't be reset thereafter.

If vault token has low decimals and high enough value, for example WBTC having 8 decimals (https://etherscan.io/token/0x2260fac5e5542a773aa44fbcfedf7c193bc2c599#code), minimumPull can block funds pulling when it is needed for Vault withdrawals.

Vulnerability Detail

Suppose BTC is USD 300k and a new Vault has USD 30k AUM. If vault token is WBTC the value of minimumPull = 0.01 WBTC will be around USD 3000, which is 10% of the Vault AUM.

In this case oftentimes withdrawals requested will not be that high, so minimumPull check can block substantial share of protocol withdrawals when it is needed to cover Vault LP withdrawal queue.

Impact

Vault withdrawal requests cannot be processed for an arbitrary time while reservedFunds and Vault balance difference is lower than threshold, i.e. LP funds will be frozen in the Vault.

Code Snippet

minimumPull is hardcoded to 10^6 on construction:

https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/Vault.sol#L90-L105

Solidity
  constructor(
    uint256 _vaultNumber,
    address _dao,
    address _controller,
    address _vaultCurrency,
    uint256 _uScale
  ) {
    controller = IController(_controller);
    vaultCurrency = IERC20(_vaultCurrency);

    vaultNumber = _vaultNumber;
    dao = _dao;
    uScale = _uScale;
    lastTimeStamp = block.timestamp;
    minimumPull = 1_000_000;
  }

For example, maxDivergenceWithdraws is hardcoded to be 10^6 in MainVault too:

https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/MainVault.sol#L50-L68

Solidity
  constructor(
    ...
  )
    VaultToken(_name, _symbol, _decimals)
    Vault(_vaultNumber, _dao, _controller, _vaultCurrency, _uScale)
  {
    ...
    maxDivergenceWithdraws = 1_000_000;
  }

But it's resettable:

https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/MainVault.sol#L418-L420

Solidity
  function setMaxDivergence(uint256 _maxDivergence) external onlyDao {
    maxDivergenceWithdraws = _maxDivergence;
  }

But minimumPull can't be reset.

It is impossible to withdraw less than minimumPull from protocols:

https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/Vault.sol#L111-L127

Solidity
  function pullFunds(uint256 _value) internal {
    uint256 latestID = controller.latestProtocolId(vaultNumber);
    for (uint i = 0; i < latestID; i++) {
      if (currentAllocations[i] == 0) continue;

      uint256 shortage = _value - vaultCurrency.balanceOf(address(this));
      uint256 balanceProtocol = balanceUnderlying(i);

      uint256 amountToWithdraw = shortage > balanceProtocol ? balanceProtocol : shortage;
      savedTotalUnderlying -= amountToWithdraw;

      if (amountToWithdraw < minimumPull) break;
      withdrawFromProtocol(i, amountToWithdraw);

      if (_value <= vaultCurrency.balanceOf(address(this))) break;
    }
  }

When Vault balance is lacking the LP withdrawals are blocked:

https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/MainVault.sol#L131-L144

Solidity
  function withdraw(
    uint256 _amount,
    address _receiver,
    address _owner
  ) external nonReentrant onlyWhenVaultIsOn returns (uint256 value) {
    value = (_amount * exchangeRate) / (10 ** decimals());

    require(value > 0, "!value");

    require(getVaultBalance() - reservedFunds >= value, "!funds");

    _burn(msg.sender, _amount);
    transferFunds(_receiver, value);
  }

Tool used

Manual Review

Recommendation

Consider introducing a setter for minimumPull, so it can be reset to a relevant level with regard to vault token decimals and its market value:

Solidity
  function setMinimumPull(uint256 _minimumPull) external onlyDao {
    minimumPull = _minimumPull;
  }

This will also allow to dynamically adjust the Vaults thereafter (say 1e6 is ok as threshold while WBTC is 20k, but becomes prohibiting when it is 200k).

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

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 minimumPull value is hardcoded in the constructor without a setter function, so it cannot be adjusted for tokens with different decimals or market values.

Impact

Vault withdrawal requests cannot be processed for an arbitrary time while reservedFunds and Vault balance difference is lower than threshold, i.e. LP funds will be frozen in the Vault.

What the attacker needed

Vault token has low decimals (e.g., 8); token value is high enough that minimumPull is significant; withdrawal amount is below minimumPull threshold

The fix

A setter function should be added to allow the DAO to adjust minimumPull.

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.

In a smart contract, some settings are fixed when the contract is created and cannot be changed later. Here, a limit called minimumPull is set to a fixed number, and if the token used has few decimals (like Bitcoin's 8), this limit becomes very large in dollar terms. This can prevent users from withdrawing their funds because the contract refuses to move small amounts.

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 hyh

View all

137 more disclosed reports, best first.

More from Derby

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.