Skip to content
Business logic Audit finding Intermediate

The protocol could not handle multiple vaults correctly

The protocol uses a single timestamp to track rebalances across all vaults, so after one vault triggers a rebalance, other vaults cannot rebalance until the interval passes. This prevents the protocol from handling multiple vaults correctly, potentially causing users and game players to lose funds.

Ch_301 Follow with SPYBOY

Originally disclosed on Sherlock

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

Found by

Ch_301, SPYBOY

Summary

The protocol needs to handle multiple vaults correctly. If there are three vaults (e.g.USDC, USDT, DAI) the protocol needs to rebalance them all without any problems

Vulnerability Detail

The protocol needs to invoke pushAllocationsToController() every rebalanceInterval to push totalDeltaAllocations from Game to xChainController.

pushAllocationsToController() invoke rebalanceNeeded() to check if a rebalance is needed based on the set interval and it uses the state variable lastTimeStamp to do the calculations

Solidity
  function rebalanceNeeded() public view returns (bool) {
    return (block.timestamp - lastTimeStamp) > rebalanceInterval || msg.sender == guardian;
  }

But in the first invoking (for USDC vault) of pushAllocationsToController() it will update the state variable lastTimeStamp to the current block.timestamp

Solidity
lastTimeStamp = block.timestamp;

Now when you invoke (for DAI vault) pushAllocationsToController(). It will revert because of

Solidity
require(rebalanceNeeded(), "No rebalance needed");

So if the protocol has two vaults or more (USDC, USDT, DAI) you can only do one rebalance every rebalanceInterval

Impact

  • The protocol could not handle multiple vaults correctly
  • Both Users and Game players will lose funds because the MainVault will not rebalance the protocols at the right time with the right values

Code Snippet

Solidity
  function pushAllocationsToController(uint256 _vaultNumber) external payable {
    require(rebalanceNeeded(), "No rebalance needed");
    for (uint k = 0; k < chainIds.length; k++) {
      require(
        getVaultAddress(_vaultNumber, chainIds[k]) != address(0),
        "Game: not a valid vaultnumber"
      );
      require(
        !isXChainRebalancing[_vaultNumber][chainIds[k]],
        "Game: vault is already rebalancing"
      );
      isXChainRebalancing[_vaultNumber][chainIds[k]] = true;
    }

Tool used

Manual Review

Recommendation

Keep tracking the lastTimeStamp for every _vaultNumber by using an array

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

Likely the protocol uses a single global timestamp (`lastTimeStamp`) to enforce the rebalance interval across all vaults, instead of tracking it per vault.

Impact

The protocol could not handle multiple vaults correctly, and both users and game players may lose funds because the main vault will not rebalance at the right time with the right values.

What the attacker needed

Protocol has two or more vaults; Rebalance interval has not passed since last rebalance

The fix

The protocol should track the last rebalance timestamp separately for each vault number, for example by using an array indexed by vault number.

How it was found

  1. Call pushAllocationsToController for the first vault (e.g., USDC), which updates lastTimeStamp to the current block.timestamp.
  2. Immediately call pushAllocationsToController for a second vault (e.g., DAI).
  3. The second call reverts because rebalanceNeeded() returns false due to the recently updated lastTimeStamp.

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 is like a digital safe where funds are stored. The protocol is supposed to regularly adjust (rebalance) the funds in each vault. But because it uses one shared timer for all vaults, after one vault is adjusted, the others are locked out until the timer resets, so they can't be adjusted on time.

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.