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.
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
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
lastTimeStamp = block.timestamp;
Now when you invoke (for DAI vault) pushAllocationsToController(). It will revert because of
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
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
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
- Call pushAllocationsToController for the first vault (e.g., USDC), which updates lastTimeStamp to the current block.timestamp.
- Immediately call pushAllocationsToController for a second vault (e.g., DAI).
- 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.