Shortfall might be calculated incorrectly if a price value for one collateral isn’t fetched correctly
Submitted by severity
Function price() of an asset doesn’t revert. It returns values (0, FIX_MAX) for low, high values of price in case there’s a problem with fetching it. Code that calls price() is able to validate returned values to detect that returned price is incorrect.
Inside function collateralShortfall() of RecollateralizationLibP1 collateral price isn’t checked for correctness. As a result incorrect value of shortfall might be calculated if there are difficulties to fetch a price for one of the collaterals.
Proof of Concept
Recommended Mitigation Steps
Check that price is correctly fetched for a collateral.
Mitigation here is a little challenging to understand considering checking a price is hard on chain and hence the concern.
I think this issue is a bit too general, but would like further comments.
tbrent (Reserve) acknowledged and commented:
I think this issue is real, but it happens in a super-corner-case that I doubt the warden is thinking about.
Some related statements:
prepareRecollateralizationTradechecks that all collateral in the basket is SOUND before callingcollateralShortfall- From
docs/collateral.md: “Should return(0, FIX_MAX)if pricing data is unavailable or stale.”
collateralShortfallshould never reach a collateral withFIX_MAXhigh price in the normal flow of things.But, it is possible for one RToken system instance to have an
RTokenAssetregistered for a 2nd RToken. In this case, it could be that RToken 2 contains a collateral plugin that is now connected to a broken oracle, but RToken 2 may not have recognized this yet. When RToken 1 callsRTokenAsset.price(), it could end up reverting because of overflow in this line fromcollateralShortfall:shortfall = shortfall.plus(needed.minus(held).mul(priceHigh, CEIL));
So I think it’s a real issue, and I would even leave it as Medium severity.
This PR simplifies and improves the basket range formula. The new logic should provide much tighter basket range estimates and result in smaller haircuts. reserve-protocol/protocol#585
Status: Mitigation confirmed with comments. Full details in reports from HollaDieWaldfee, 0xA5DF, and AkshaySrivastav.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity doS bug in Reserve Core. Code4rena made it public on 27 April 2023. Found in the 2023-01-reserve audit contest (finding M-20).
About DoS
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
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.