Submitted by 0xdeadbeef0x, also found by __141345__, severity, severity, severity, and severity
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/assets/CTokenFiatCollateral.sol#L45
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/assets/CTokenFiatCollateral.sol#L37
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/AssetRegistry.sol#L50
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L300
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/AssetRegistry.sol#L87
Asset plugins assume underlying collateral tokens will always behave as they are expected at the time of the plugin creation. This assumption can be incorrect because of multiple reasons such as upgrades/rug pulls/hacks.
In case a single collateral token in a basket of assets causes functions in the asset to fail the whole RToken functionality will be broken.
This includes (and not limited to):
The impacts become permanent as the unregistering of bad collateral assets is also dependent on collateral token behavior.
Emphasis of funds lost:
Lets assume a CTokenFiatCollateral of cUSDP is registered as an asset in AssetRegistry.
One day, cUSDP deployer gets hacked and the contract self-destructs, therefore any call to the cUSDP contract will fail.
cUSDP is a proxy contract:
https://etherscan.io/address/0x041171993284df560249B57358F931D9eB7b925D#readProxyContract
Note: There could be other reasons that calls to cUSDP will revert such as:
Bad collateral assets cannot be unregistered
Lets describe the flow of unregistering an asset from the AssetRegistry:
governance needs to call unregister in order to unregister and asset:
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/AssetRegistry.sol#L87
As can seen above, basketHandler.quantity(asset.erc20()); is called as part of the unregister flow.
quantity function in basketHandler:
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/BasketHandler.sol#L300
The asset is still registered so the try call will succeed and coll.refPerTok(); will be called.
refPerTok function in CTokenFiatCollateral (which is used as an asset of cUSDP):
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/assets/CTokenFiatCollateral.sol#L45
If ICToken(address(erc20)).exchangeRateStored(); will revert because of the previously defined reasons (hack, upgrade, etc..), the whole unregister call will be a reverted.
Explanation of Impact
As long as the asset is registered and cannot be removed (explained above), many function calls will revert and cause the impacts in the impact section.
The main reason is the refresh function of CTokenFiatCollateral (used for cUSDP) depends on a call to cUSDP exchangeRateCurrent function.
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/plugins/assets/CTokenFiatCollateral.sol#L37
AssetRegistrys refresh function calls refresh to all registered assets:
https://github.com/reserve-protocol/protocol/blob/df7ecadc2bae74244ace5e8b39e94bc992903158/contracts/p1/AssetRegistry.sol#L50
In our case, CTokenFiatCollateral.refresh() will revert therefore the call to AssetRegistry.refresh() will revert.
AssetRegistry.refresh() is called in critical functions that will revert:
Foundry, VS Code
For plugins to function as intended there has to be a dependency on protocol specific function.
In a case that the collateral token is corrupted, the governance should be able to replace to corrupted token. The unregistering flow should never be depended on the token functionality.
0xean (judge) decreased severity to Medium and commented:
tbrent (Reserve) confirmed and commented:
tbrent (Reserve) mitigated:
Status: Not fully mitigated. Full details in report from AkshaySrivastav, and also included in Mitigation Review section below.
