Pending CRV rewards are not accounted for and can cause unfair liquidations
The WCurveGauge contract's pendingRewards function returns empty arrays, so pending CRV rewards are not included when valuing a position. This can cause users to be unfairly liquidated because their collateral is undervalued.
Source: https://github.com/sherlock-audit/2023-04-blueberry-judging/issues/136
Found by
0x52
Summary
pendingRewards are factored into the health of a position so that the position collateral is fairly assessed. However WCurveGauge#pendingRewards doesn't return the proper reward tokens/amounts meaning that positions aren't valued correctly and users can be unfairly liquidated.
Vulnerability Detail
(address[] memory tokens, uint256[] memory rewards) = IERC20Wrapper(
pos.collToken
).pendingRewards(pos.collId, pos.collateralSize);
for (uint256 i; i < tokens.length; i++) {
rewardsValue += oracle.getTokenValue(tokens[i], rewards[i]);
}
When BlueBerryBank is valuing a position it also values the pending rewards since they also have value.
function pendingRewards(
uint256 tokenId,
uint256 amount
)
public
view
override
returns (address[] memory tokens, uint256[] memory rewards)
{}
Above we see that WCurveGauge#pendingRewards returns empty arrays when called. This means that pending rewards are not factored in correctly and users can be liquidated when even when they should be safe.
Impact
User is liquidated when they shouldn't be
Code Snippet
Tool used
Manual Review
Recommendation
Change WCurveGauge#pendingRewards to correctly return the pending rewards
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
The pendingRewards function in WCurveGauge is unimplemented and returns empty arrays instead of the actual pending reward tokens and amounts.
Impact
Users could be liquidated even when their position should be safe, because pending rewards are not counted towards collateral value.
What the attacker needed
Position with pending CRV rewards
The fix
The pendingRewards function should be implemented to correctly return the pending reward tokens and amounts.
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.
When you borrow money using collateral, the system checks if your collateral is worth enough to cover the loan. If it thinks your collateral is worth less than it really is, it might sell it off (liquidate) even though you are safe. Here, a function that should report extra rewards you have earned returns nothing, so the system undervalues your collateral.
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.