Platform: Code4rena
Start Date: 04/03/2024
Pot Size: $88,500 USDC
Total HM: 31
Participants: 105
Period: 11 days
Judge: ronnyx2017
Total Solo HM: 7
Id: 342
League: ETH
Rank: 97/105
Findings: 1
Award: $10.29
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Bauchibred
Also found by: 0x11singh99, 0x175, 0xAlix2, 0xDemon, 0xGreyWolf, 0xPhantom, 0xspryon, 14si2o_Flint, Arabadzhiev, Aymen0909, Bigsam, BowTiedOriole, CRYP70, DanielArmstrong, FastChecker, JecikPo, KupiaSec, MohammedRizwan, Norah, Timenov, Topmark, VAD37, adeolu, btk, crypticdefense, cryptphi, givn, grearlake, jnforja, kennedy1030, kfx, ktg, lanrebayode77, n1punp, santiellena, stonejiajia, t4sk, thank_you, tpiliposian, wangxx2026, y0ng0p3, zaevlad
10.2896 USDC - $10.29
https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Oracle.sol#L324
When price rallies, for example, in the case of UNI price spiked recently, TWAP may not be able to catch up easily with Chainlink price oracle. Hence, if the price diff is set too small, then the V3Oracle will revert. This means users will not be able to modify any of the positions, including liquidators. If price continues to rally, then this can end up with bad debt into the system due to underwater positions (see CompoundV2's case here: https://twitter.com/ChainLinkGod/status/1761061618983841828. This event has caused $3m bad debt to Compound v2 since TWAP did not catch up, causing oracle reverts during the UNI price pump).
The V3Oracle can read the price from 2 main sources: Chainlink and TWAP to sanity check the values. If the difference exceeds the set threshold, then the oracle reverts.
Now, if the threshold is too low, then the oracle reverts as in the UNI case mentioned above. If it is set too high, then the spot price becomes more manipulatable (since the same threshold is used for TWAP deviation and the spot price deviation), and the Uniswap V3 position can be priced incorrectly and can lead to bad liquidation (for example, the liquidator can manipulate the price of LP to be lower than what it should be, and triggers the liquidation, and getting higher shares of LP -> getting even more value).
Manual Review
Oracle
#0 - c4-pre-sort
2024-03-19T10:05:26Z
0xEVom marked the issue as sufficient quality report
#1 - c4-pre-sort
2024-03-19T10:05:28Z
0xEVom marked the issue as primary issue
#2 - 0xEVom
2024-03-25T08:52:34Z
Medium severity due to external assumptions.
Related: #223
#3 - kalinbas
2024-03-27T16:16:00Z
Initial thoughts: There is another parameter which is TWAP period which we plan to set much lower than for example compound to react faster to price changes. Of course there is still the same risk but it is much smaller. Because we use TWAP only to verify prices the period may be lower, as manipulation only leads to temporary disabled liquidations.
#4 - kalinbas
2024-03-27T16:19:41Z
"This means users will not be able to modify any of the positions" - this is not 100% true. You may always repay positions
#5 - mariorz
2024-03-27T20:20:42Z
There seem to be a few misunderstandings regarding how our protocol works that make this report invalid.
The case of Compound is different in a few important ways:
What happened with the UNI example with Compound
What would have happened to Revert Lend:
While it's true that there is a risk where in the inverse case, when the price of a collateral asset crashes suddenly and the TWAP price lags, liquidations will be halted potentially putting the protocol in a bad debt state for a subset of positions. We believe this an acceptable trade-off given our TWAP period length, and collateral asset caps, in order to not solely depend on chainlink as the only price source. You will notice that, for example Maker, has a longer threshold for price updates than our TWAP period.
#6 - c4-sponsor
2024-03-27T20:20:47Z
mariorz (sponsor) disputed
#7 - jhsagd76
2024-03-30T23:48:16Z
I believe that the warden, the sponsor, myself have no technical misunderstanding regarding this issue, and I don't think it meets the criteria for an H/M severity level.
For an H severity, the rules require the issue to be able to cause definite loss to the protocol without harsh preconditions. This issue has very rare preconditions and clearly does not meet the standard for high severity.
Secondly, for an M level, we require the issue to cause a functional disruption to the protocol. We all understand that TWAP is designed to work this way, and the sponsor has also explained that their use of and the risks associated with TWAP are completely in line with expectations and design. Therefore, I don't believe it really breaks any functionality.
#8 - c4-judge
2024-03-30T23:49:13Z
jhsagd76 changed the severity to QA (Quality Assurance)
#9 - jhsagd76
2024-03-30T23:49:37Z
N
#10 - c4-judge
2024-03-31T03:47:34Z
jhsagd76 marked the issue as grade-b