Revert Lend - kodyvim's results

A lending protocol specifically designed for liquidity providers on Uniswap v3.

General Information

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

Revert

Findings Distribution

Researcher Performance

Rank: 19/105

Findings: 1

Award: $737.08

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: Bauchibred

Also found by: Giorgio, grearlake, kodyvim

Labels

bug
3 (High Risk)
satisfactory
sufficient quality report
upgraded by judge
:robot:_127_group
duplicate-127

Awards

737.0773 USDC - $737.08

External Links

Lines of code

https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/V3Oracle.sol#L346 https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/automators/Automator.sol#L187

Vulnerability details

Impact

If tickCumulatives[1] - tickCumulatives[0] is negative and ((tickCumulatives[1] - tickCumulatives[0]) % twapSeconds != 0, then returned tick will be bigger than it should be.

Proof of Concept

In V3Oracle contract, function _getReferencePoolPriceX96() is used by protocol to get average price.

The problem is that in case if tickCumulatives[1] - tickCumulatives[0] is negative, then timeWeightedTick should be rounded down like Uniswap library

As result, in case if tickCumulatives[1] - tickCumulatives[0] is negative and (tickCumulatives[1] - tickCumulatives[0]) % twapSeconds != 0, tick will be bigger then it should be. Which opens possibility for arbitrage opportunities.

Other instance of same issue: https://github.com/code-423n4/2024-03-revert-lend/blob/main/src/automators/Automator.sol#L187

Tools Used

Manual Review

Tick should be rounded down in this case:

    int24 tick = int24((tickCumulatives[0] - tickCumulatives[1]) / int56(uint56(twapSeconds)));
 +  if ((tickCumulatives[1] - tickCumulatives[0]) < 0 && ((tickCumulatives[1] - tickCumulatives[0]) % twapSeconds != 0)) tick--;

Assessed type

Context

#0 - c4-pre-sort

2024-03-22T07:16:09Z

0xEVom marked the issue as primary issue

#1 - c4-pre-sort

2024-03-22T07:16:17Z

0xEVom marked the issue as sufficient quality report

#2 - c4-pre-sort

2024-03-22T07:18:51Z

0xEVom marked the issue as duplicate of #498

#3 - c4-pre-sort

2024-03-25T12:11:36Z

0xEVom marked the issue as duplicate of #127

#4 - c4-judge

2024-04-01T08:25:21Z

jhsagd76 marked the issue as satisfactory

#5 - c4-judge

2024-04-01T15:41:25Z

jhsagd76 changed the severity to 3 (High Risk)

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter