Skip to content
DoS Audit finding Intermediate

`getDecimals()` always call the MainNet

The function pushVaultAmounts calls getDecimals on a vault address that may be on a different chain, causing it to revert or return wrong decimals, which breaks rebalancing logic.

Ch_301 Follow

Originally disclosed on Sherlock

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

Found by

Ch_301

Summary

XChainController.pushVaultAmounts() is to push exchangeRate to the vaults. XChainController.getVaultAddress() returns the vault address of vaultNumber with the given chainID

Vulnerability Detail

pushVaultAmounts() invoke xProvider.getDecimals() internally to calculate newExchangeRate

The xProvider.getDecimals() is always call the address(vault) from the MainNet. but address(vault) could be in any chain XChainController.pushVaultAmounts() could keep reverting with all the chainID (only the MainNet will be correct ) or it will return the wrong decimals values. (if the address(vault) is for other chain/L but it exist in the MainNet with a decimals())
this will lead to a wrong newExchangeRate

Solidity
uint256 newExchangeRate = (totalUnderlying * (10 ** decimals)) / totalSupply;

Impact

pushVaultAmounts() will keep reverting and this will break all rebalancing logic

Code Snippet

Solidity
  function pushVaultAmounts(
    uint256 _vaultNumber,
    uint16 _chain
  ) external payable onlyWhenUnderlyingsReceived(_vaultNumber) {
    address vault = getVaultAddress(_vaultNumber, _chain);
    require(vault != address(0), "xChainController: not a valid vaultnumber");
    /*...*/

    uint256 decimals = xProvider.getDecimals(vault);
    uint256 newExchangeRate = (totalUnderlying * (10 ** decimals)) / totalSupply;

    /*...*/
  }

Tool used

Manual Review

Recommendation

You should invoke getVaultAddress() with _chain of the Mainnet. because all vaults have the same getDecimals (not all vaultNamber)

Discussion

Ch-301

Escalate for 10 USDC

we know that the XChainController is on the mainnet and it can only call xProvider on the same chain (mainnet).

The flow:

  • XChainController.pushVaultAmounts() invoke getVaultAddress() internally
  • XChainController.getVaultAddress() return the vault address of vaultNumber with the given chainID.

So getVaultAddress() is not guarantee that the returned address is on the mainnet

  • After that XChainController.pushVaultAmounts() invoke xProvider.getDecimals() internally
Solidity
  /// @notice returns number of decimals for the vault
  function getDecimals(address _vault) external view returns (uint256) {
    return IVault(_vault).decimals();
  }

As we can see xProvider.getDecimals() only interact with the mainnet in this case. This will lead XChainController.pushVaultAmounts() to revert and break all rebalancing logic. I believe this issue should be valid.

sherlock-admin

Escalate for 10 USDC

we know that the XChainController is on the mainnet and it can only call xProvider on the same chain (mainnet).

The flow:

  • XChainController.pushVaultAmounts() invoke getVaultAddress() internally
  • XChainController.getVaultAddress() return the vault address of vaultNumber with the given chainID. So getVaultAddress() is not guarantee that the returned address is on the mainnet
  • After that XChainController.pushVaultAmounts() invoke xProvider.getDecimals() internally
Solidity
  /// @notice returns number of decimals for the vault
  function getDecimals(address _vault) external view returns (uint256) {
    return IVault(_vault).decimals();
  }

As we can see xProvider.getDecimals() only interact with the mainnet in this case. This will lead XChainController.pushVaultAmounts() to revert and break all rebalancing logic. I believe this issue should be valid.

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

This is a 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.

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

What the attacker needed

None

The fix

The function should call getVaultAddress with the mainnet chain ID, because all vaults have the same decimals.

How it was found

  1. Call pushVaultAmounts with a vault number and a chain ID that is not the mainnet.
  2. The function internally calls getVaultAddress to get the vault address for that chain.
  3. It then calls xProvider.getDecimals on that address, which only works on the mainnet.
  4. The call reverts or returns wrong decimals, causing the exchange rate calculation to fail or be incorrect.

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 tries to read data from another blockchain, but it can only read from its own chain. So when it tries to get the number of decimals for a vault on another chain, it fails or gets the wrong number, which stops the system from updating balances correctly.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.