Skip to content
Business logic Audit finding Intermediate

When one of the plugins is broken or paused, `deposit()` or `withdraw()` of the whole Vault contract can malfunction

The Vault contract deposits to the first plugin and withdraws from the last plugin, so if one plugin (such as Aave V2) is paused, all deposit and withdraw operations fail. An attacker cannot directly exploit this, but users are unable to deposit or withdraw, and the owner cannot remove or rebalance the plugin to restore operation.

ctf_sec Follow with IllIllI, berndartmueller and 2 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-10-mycelium-judging/tree/main/006-M

Found by

ctf_sec, IllIllI, berndartmueller, ak1, WATCHPUG

Summary

One malfunctioning plugin can result in the whole Vault contract malfunctioning.

Vulnerability Detail

A given plugin can temporally or even permanently becomes malfunctioning (cannot deposit/withdraw) for all sorts of reasons.

Eg, Aave V2 Lending Pool can be paused, which will prevent multiple core functions that the Aave v2 plugin depends on from working, including lendingPool.deposit() and lendingPool.withdraw().

https://github.com/aave/protocol-v2/blob/master/contracts/protocol/lendingpool/LendingPool.sol#L54

SOLDITY
  modifier whenNotPaused() {
    _whenNotPaused();
    _;
  }

https://github.com/aave/protocol-v2/blob/master/contracts/protocol/lendingpool/LendingPool.sol#L142-L146

Solidity
  function withdraw(
    address asset,
    uint256 amount,
    address to
  ) external override whenNotPaused returns (uint256) {

That's because the deposit will always goes to the first plugin, and withdraw from the last plugin first.

Impact

When Aave V2 Lending Pool is paused, users won't be able to deposit or withdraw from the vault.

Neither can the owner remove the plugin nor rebalanced it to other plugins to resume operation.

Because withdrawal from the plugin can not be done, and removing a plugin or rebalancing both rely on this.

Code Snippet

https://github.com/sherlock-audit/2022-10-mycelium/blob/main/mylink-contracts/src/Vault.sol#L456-L473

https://github.com/sherlock-audit/2022-10-mycelium/blob/main/mylink-contracts/src/Vault.sol#L492-L519

Tool used

Manual Review

Recommendation

  1. Consider introducing a new method to pause one plugin from the Vault contract level;

  2. Aave V2's Lending Pool contract has a view function paused(), consider returning 0 for availableForDeposit() and ``availableForWithdrawal() when pool paused in AaveV2Plugin:

Solidity
function availableForDeposit() public view override returns (uint256) {
    if (lendingPool.paused()) return 0;
    return type(uint256).max - balance();
}
Solidity
function availableForWithdrawal() public view override returns (uint256) {
    if (lendingPool.paused()) return 0;
    return balance();
}

The original report as published on Sherlock, by ctf_sec. 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

The Vault contract always deposits to the first plugin and withdraws from the last plugin, without checking whether a plugin is available or handling a paused plugin.

What the attacker needed

Aave V2 Lending Pool is paused; Vault uses Aave V2 plugin

The fix

The recommendation is to add a method to pause a plugin from the Vault contract level and to make the Aave V2 plugin return 0 for availableForDeposit and availableForWithdrawal when the lending pool is paused.

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 vault contract holds user funds and puts them into external 'plugins' to earn interest. If one plugin stops working (for example, because the outside service is paused), the vault's deposit and withdraw functions break for everyone, and the owner cannot fix it because removing or rebalancing the plugin also requires withdrawing from it.

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 ctf_sec

View all

25 more disclosed reports, best first.

More from Mycelium

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.