The Furnace#melt() is vulnerable to sandwich attacks
Submitted by wait
Malicious users can get more of the RToken appreciation benefit brought by Furnace.sol#melt(), and long-term RToken holders will get less benefit.
RToken holders will be less willing to provide liquidity to RToken pools (such as uniswap pools), resulting in less liquidity of RToken.
Proof of Concept
A1. Gain revenue from a flashloan sandwich attack
A malicious user can launch a flashloan sandwich attack against Furnace#melt() each time a whole period passed (payout happens).
The attack transaction execution steps:
- Borrow some assets (
inputFund) with a flashloan - Swap the
inputFundfor RToken - Call RToken#redeem() to change the RToken to basket assets(
outputFund). Theredeem()will invokeFurnace.melt()automatically. - Swap part of
outputFundforinputFundand pay back the flashloan, the rest ofoutputFundis the profit.
The implicit assumption here is that most of the time the prices of RToken in RToken.issues(), RToken.redeem(), and DeFi pools are almost equal.
This assumption is reasonable because if there are price differentials, they can be balanced by arbitrage.
The attack can be profitable for:
Furnace#melt()will increase the price of RToken in issue/redeem (according to basket rate).- Step 2 buys RTokens at a lower price, and then step 3 sells RTokens at a higher price(
melt()is called first inredeem()).
A2. Get a higher yield by holding RToken for a short period of time
Malicious users can get higher yield by by following these steps:
- Calculate the next payout block of Furnace in advance
- Call RToken#issue() 1 to n blocks before the payout block
- Call RToken#redeem() when the payout block reaches.
Since this approach only requires 1 to n blocks to issue in advance, which is typically much smaller than rewardPeriod, the attacker will obtain much higher APR than long-term RToken holders.
Recommended Mitigation Steps
Referring to eip-4626, distribute rewards based on time weighted shares.
Alternatively, always use a very small rewardPeriod and rewardRatio, and lower the upper limit MAXRATIO and MAXPERIOD.
0xean (judge) decreased severity to Medium
Agreed with the warden. And agree this is a Medium severity issue.
(aside: we are already planning to fix the period at 12s to mitigate this issue)
Addressed here: https://github.com/reserve-protocol/protocol/pull/571
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 business logic bug in Reserve Core. Code4rena made it public on 27 April 2023. Found in the 2023-01-reserve audit contest (finding M-15).
About Business logic
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
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.