code-423n4 / 2023-11-betafinance-findings

1 stars 1 forks source link

Requesting the price for the native token in the bnb chain using the band oracle will request the price of ETH instead of the price of BNB, which will end up messing the accounting by considering 1BNB to be worth 1ETH. #30

Open c4-submissions opened 11 months ago

c4-submissions commented 11 months ago

Lines of code

https://github.com/code-423n4/2023-11-betafinance/blob/main/Omni_Protocol/src/OmniOracle.sol#L45-L47

Vulnerability details

Impact

Proof of Concept

OmniOracle contract

//@audit-info => Returns the price in a scale of 1e36 of the given _underlying asset
function getPrice(address _underlying) external view returns (uint256) {
OracleConfig memory config = oracleConfigs[_underlying];
if (config.provider == Provider.Band) {
IStdReference.ReferenceData memory data;
if (_underlying == WETH) {
//@audit-issue => If the underlying asset matches the address of the wrapped native token contract, it will request the price of the ETH/USD pair
//@audit-info => For mainnet, it's okay to request the price of ETH/UST
//@audit-issue => In the BNB chain, requesting the price of ETH/USD will cause each BNB to be considered worth 1ETH
//@audit-issue => In the BNB chain is required to request the price of the BNB/USD pair.
data = IStdReference(config.oracleAddress).getReferenceData("ETH", USD);
} else {
data = IStdReference(config.oracleAddress).getReferenceData(IERC20Metadata(_underlying).symbol(), USD);
}
...
}
...
...
}

Tools Used

Manual Audit

Recommended Mitigation Steps

Assessed type

Context

JeffCX commented 11 months ago

duplicate of #22

thereksfour commented 11 months ago

There is an assumption that WETH will be set to WBNB address on BSC, will consider QA, and leave it to sponsors

c4-judge commented 11 months ago

thereksfour marked the issue as primary issue

stalinMacias commented 11 months ago

@thereksfour more than an assumption that WETH will be set to WBNB address on BSC, it is a fact, first of all, there is a comment in the code that explictly acknowledges this fact.

And supposing that the address of the WETH contract is not updated and leave it as it is, this would even be a bigger problem, there is no a WETH contract in the BNB chain, so, that means that all the deposited native token (BNB) will be unnusable, the reason is because the WBNB contract won't match the current hardcoded address of the WETH contract, so, the request to the Band oracle will send the symbol assigned in the WBNB contract, which is "WBNB", check it here, which will cause the tx to revert because the Band oracle doesn't support the WBNB/USD pair, check here, it only supports the BNB/USD Pair

    function getPrice(address _underlying) external view returns (uint256) {
        OracleConfig memory config = oracleConfigs[_underlying];
        if (config.provider == Provider.Band) {
            IStdReference.ReferenceData memory data;
//@audit-issue => If the hardcoded WETH address is not updated to the WBNB address in the BNB chain, when the OmniPool requests the price for the WBNB contract it won't enter this condition, it will go with the code in the else block
            if (_underlying == WETH) {
                data = IStdReference(config.oracleAddress).getReferenceData("ETH", USD);
            } else {
//@audit-issue => If the Oracle requests the price of the WBNB/USD pair, the tx will revert because that pair is not supported in the Band oracle, it only supports the BNB/USD pair
                data = IStdReference(config.oracleAddress).getReferenceData(IERC20Metadata(_underlying).symbol(), USD);
            }
   ...

So, I still think this problem deserves a medium severity.

thereksfour commented 11 months ago

As discussed in #22, I don't think Band Oracle will be used on BSC to get prices for ETH or BNB as they are unsupported.

allenjlee commented 11 months ago

As mentioned in #22 I believe there was a QA report #23 that brought this up as well. I agree, the oracle implementation is not the cleanest, but I think it just puts more onus on the deployer to make sure that things are deployed correctly. I don't really think this is a medium severity, and more of a QA issue. I think the argument here is mostly that we shouldn't put so much dependency on the deployer with the contracts, which is a fair point.

Also regarding lack of support by Band, this is explicitly why we also handle support with Chainlink. It's not like all market addresses must be supported by Band. We will use either Chainlink or Band depending on what is available and reliable.

c4-sponsor commented 11 months ago

allenjlee marked the issue as disagree with severity

c4-sponsor commented 11 months ago

allenjlee (sponsor) acknowledged

c4-judge commented 11 months ago

thereksfour changed the severity to QA (Quality Assurance)