Skip to content
Business logic Audit finding Intermediate

Deposited funds are locked in inactive vaults

Users cannot request withdrawal of their funds from inactive vaults because the withdrawalRequest function is blocked by a modifier that only allows calls when the vault is active. An attacker could not directly exploit this, but users' funds could be locked in an inactive vault for a prolonged period if the vault receives zero allocations from gamers.

Ch_301 Follow with Jeiwan, Met and 1 other

Originally disclosed on Sherlock

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

Found by

Ch_301, Jeiwan, Met, saidam017

Summary

Users cannot request withdrawal of their funds from inactive vaults: if a vault receives 0 allocations from gamers, only previous withdrawal requests can be process and new requests cannot be made.

Vulnerability Detail

During rebalancing, if a vault receives 0 allocations from gamers, it becomes inactive. MainVault doesn't allow calling these functions on an inactive vault:

  1. deposit, which makes sense because the vault doesn't generate yield and users shouldn't be allowed to deposit funds in such vaults;
  2. withdraw, which also makes sense because the vault holds no funds, so immediate withdrawals are not possible;
  3. withdrawalRequest, which seems wrong because this doesn't allow users to withdraw funds after next rebalancing.

Since inactive vaults don't receive funds during rebalancing, it expected that immediate withdrawals via the withdraw function are disabled (inactive vaults don't hold funds, thus funds cannot be withdrawn immediately). However, disallowing withdrawalRequest seems like a mistake: users who have deposited their funds into an inactive vault and who are still holding shares of the vault might decide, after seeing that the vault haven't received allocations during last rebalancing (e.g. protocols on other networks might generate higher yields and gamers might want to direct all allocations to those protocols), to withdraw their funds. withdrawalRequest allows them to request withdrawal after next rebalancing, which is a crucial feature of the protocol.

Impact

In the worst case scenario, user funds can be locked in an inactive vault for a prolonged period of time. E.g. if the vault is deployed in a network where yield generating protocols produce lower APY than protocols on other networks. In this scenario, gamers will be willing to allocate to more profitable protocols, but depositors of the inactive vault will be forced to keep their funds locked in the vault until on-chain conditions change (which are not controlled by users, e.g. users cannot force a protocol to have a higher APY).

Code Snippet

  1. When XChainController receives allocations, it disables vault that have 0 allocations and that haven't received new allocations:

https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/XChainController.sol#L229-L235

  1. Withdrawals cannot be requested in inactive vaults due to the onlyWhenVaultIsOn modifier:

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

  1. withdrawAllowance can only withdraw funds when there's a withdrawal request:

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

Tool used

Manual Review

Recommendation

Consider allowing users call withdrawalRequest to request withdrawal in inactive vault. During rebalancing, inactive vaults with positive withdrawalRequest should receive enough funds for all requests to be processed.

Discussion

sjoerdsommen

Duplicate with https://github.com/sherlock-audit/2023-01-derby-judging/issues/318 https://github.com/sherlock-audit/2023-01-derby-judging/issues/211 https://github.com/sherlock-audit/2023-01-derby-judging/issues/137

hrishibhat

Given the necessary preconditions for the issue to happen considering this issue as a valid medium

The original report as published on Sherlock, by Ch_301. 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 withdrawalRequest function is restricted by the onlyWhenVaultIsOn modifier, which prevents users from requesting withdrawals from inactive vaults.

Impact

User funds can be locked in an inactive vault for a prolonged period, as users cannot request withdrawals until the vault becomes active again, which depends on external conditions like yield rates.

What the attacker needed

Vault becomes inactive (0 allocations); user has funds deposited in that vault

The fix

The withdrawalRequest function should be allowed in inactive vaults, and during rebalancing, inactive vaults with pending withdrawal requests should receive enough funds to process them.

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 this system, users deposit funds into vaults, and 'gamers' decide how to allocate those funds across different protocols. If a vault gets no allocations, it becomes inactive, and the code prevents users from requesting to withdraw their money from it. This means their funds can get stuck until the vault becomes active again, which is outside the users' control.

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 Ch_301

View all

39 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.