You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 5, 2023. It is now read-only.
sherlock-admin opened this issue
Apr 30, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
When an external protocol adds a new reward token, oracle does not support getting the price of this token. This will cause BlueBerryBank#getPositionValue to revert, causing all transactions that call this function to fail.
Vulnerability Detail
BlueBerryBank#getPositionValue is used to calculate the value of a certain position, including collateral token and reward tokens of external protocols. It uses the IERC20Wrapper#pendingRewards function to get the reward token array of the external protocol, and then get the price of each reward token by CoreOracle#getTokenValue.
Obviously, a new reward token has no route. Eventually BlueBerryBank#getPositionValue will revert. Therefore, functions that call this function will revert. Here I give the flow of the two functions:
Both BlueBerryBank#liquid and BlueBerryBank#execute will be affected. Due to the importance of liquidation time, untimely liquidation can result in financial losses for both parties involved in the liquidation.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelMediumA valid Medium severity issueRewardA payout will be made for this issue
nobody2018
medium
Liquidation will fail in certain scenario
Summary
When an external protocol adds a new reward token, oracle does not support getting the price of this token. This will cause
BlueBerryBank#getPositionValue
to revert, causing all transactions that call this function to fail.Vulnerability Detail
BlueBerryBank#getPositionValue
is used to calculate the value of a certain position, including collateral token and reward tokens of external protocols. It uses theIERC20Wrapper#pendingRewards
function to get the reward token array of the external protocol, and then get the price of each reward token byCoreOracle#getTokenValue
.CoreOracle#getTokenValue
internally calls the_getPrice
function, which checks whether the value of routes[token] is non-zero.Obviously, a new reward token has no
route
. EventuallyBlueBerryBank#getPositionValue
will revert. Therefore, functions that call this function will revert. Here I give the flow of the two functions:BlueBerryBank#liquidate
->isLiquidatable->getPositionRisk->getPositionValue->oracle.getTokenValueBlueBerryBank#execute
->isLiquidatable->getPositionRisk->getPositionValue->oracle.getTokenValueImpact
Both
BlueBerryBank#liquid
andBlueBerryBank#execute
will be affected. Due to the importance of liquidation time, untimely liquidation can result in financial losses for both parties involved in the liquidation.Code Snippet
https://github.com/sherlock-audit/2023-04-blueberry/blob/main/blueberry-core/contracts/BlueBerryBank.sol#L408-L413
https://github.com/sherlock-audit/2023-04-blueberry/blob/main/blueberry-core/contracts/oracle/CoreOracle.sol#L74
Tool used
Manual Review
Recommendation
Duplicate of #115
The text was updated successfully, but these errors were encountered: