Lack of claimRewards when manageToken in RevenueTrader
The RevenueTrader's manageToken function refreshes assets before trading but does not claim their pending rewards, so reward tokens can be left unclaimed during a revenue auction. An attacker cannot directly exploit this, but the protocol may lose rewards or complete auctions at worse slippage than necessary.
Originally disclosed on Code4rena
Submitted by ronnyx2017
There is a dev comment in the Assert.sol:
DEPRECATED: claimRewards() will be removed from all assets and collateral plugins
The claimRewards is moved to the TradingP1.claimRewards/claimRewardsSingle.
But when the RevenueTraderP1 trade and distribute revenues by manageToken, it only calls the refresh function of the asserts:
if (erc20 != IERC20(address(rToken)) && tokenToBuy != IERC20(address(rToken))) {
IAsset sell_ = assetRegistry.toAsset(erc20);
IAsset buy_ = assetRegistry.toAsset(tokenToBuy);
if (sell_.lastSave() != uint48(block.timestamp)) sell_.refresh();
if (buy_.lastSave() != uint48(block.timestamp)) buy_.refresh();
}
The claimRewards is left out.
Impact
Potential loss of rewards.
Recommended Mitigation Steps
Add claimRewardsSingle when refresh assert in the manageToken.
tbrent (Reserve) disputed and commented:
This is similar to an (unmitigated) issue from an earlier audit: https://github.com/code-423n4/2023-02-reserve-mitigation-contest-findings/issues/22
However in this case it has to do with
RevenueTraderP1.manageToken(), as opposed toBackingManagerP1.manageTokens().I think that difference matters, because the loss of the rewards for this auction does not have serious long-term consequences. This is not like the BackingManager where it’s important that all capital always be available else an unnecessarily large haircut could occur. Instead, the worst that can happen is for the revenue auction to complete at high slippage, and for a second reward token revenue auction to complete afterwards at high slippage yet again, when it could have been a single revenue auction with less slippage.
The recommended mitigation would not succeed, because recall, we may be selling token X but any number of additional assets could have token X as a reward token. We would need to call
claimRewards(), which is simply too gas-costly to do everytime for revenue auctions.
Instead, the worst that can happen is for the revenue auction to complete at high slippage, and for a second reward token revenue auction to complete afterwards at high slippage yet again, when it could have been a single revenue auction with less slippage.
@tbrent - The impact sounds like a “leak of value” and therefore I think Medium is the correct severity per the c4 docs. (cc @tbrent - open to additional comment here)
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
Impact
Rewards for the auction may be lost, and revenue auctions could complete at higher slippage than if rewards had been claimed and combined; the text notes this has no serious long-term consequences.
What the attacker needed
Revenue auction involving reward-bearing assets
The fix
The project disputed the finding, arguing that calling claimRewards every time would be too gas-costly, so no fix was applied.
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.
Some tokens pay out extra 'reward' tokens to whoever holds them. A smart contract that trades these tokens should collect those rewards first, otherwise they are wasted. Here the trading function forgot to collect them, so the project may miss out on free tokens.
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.