Asking for `balanceOf()` in the wrong address
The sendFundsToVault function retrieves the underlying token address for a specified chain, but when the chain is Optimism (L2), it calls balanceOf on that L2 token address while the contract is on Mainnet, which is invalid. This prevents the protocol from rebalancing the vault.
Source: https://github.com/sherlock-audit/2023-01-derby-judging/issues/170
Found by
Ch_301
Summary
Vulnerability Detail
on sendFundsToVault() this logic
address underlying = getUnderlyingAddress(_vaultNumber, _chain);
uint256 balance = IERC20(underlying).balanceOf(address(this));
in case _chainId is Optimism
the underlying address is for Optimism (L2)
but XChainController is on Mainnet
you can't invoke balanceOf() like this!!!
Impact
Asking for balanceOf() in the wrong address
The protocol will be not able to rebalance the vault
Code Snippet
Tool used
Manual Review
Recommendation
getUnderlyingAddress(_vaultNumber, _chain); should just be getUnderlyingAddress(_vaultNumber);
so the underlying here
uint256 balance = IERC20(underlying).balanceOf(address(this));
will be always on the Mainnet
Discussion
Ch-301
Escalate for 10 USDC
This one was confirmed by the Sponsor check the discussion for more details
sherlock-admin
Escalate for 10 USDC
This one was confirmed by the Sponsor check the discussion for more details
You've created a valid escalation for 10 USDC!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Theezr
Valid medium issue
hrishibhat
Escalation accepted
Considering this issue a valid medium
sherlock-admin
Escalation accepted
Considering this issue a valid medium
This issue's escalations have been accepted!
Contestants' payouts and scores will be updated according to the changes made on this issue.
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 function uses a chain-specific underlying token address without accounting for the fact that the contract only operates on Mainnet, leading to an invalid cross-chain balance query.
Impact
The protocol will be unable to rebalance the vault.
What the attacker needed
None
The fix
The function should use the Mainnet underlying token address by calling getUnderlyingAddress without the chain parameter.
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 smart contract on one blockchain (Mainnet) cannot directly ask for the balance of a token that exists on a different blockchain (Optimism). The code mistakenly uses the address of the Optimism token when checking the balance on Mainnet, so the check fails and the vault cannot be rebalanced.
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.