Good Entry - auditsea's results

The best day trading platform to make every trade entry a Good Entry.

General Information

Platform: Code4rena

Start Date: 01/08/2023

Pot Size: $91,500 USDC

Total HM: 14

Participants: 80

Period: 6 days

Judge: gzeon

Total Solo HM: 6

Id: 269

League: ETH

Good Entry

Findings Distribution

Researcher Performance

Rank: 28/80

Findings: 1

Award: $482.48

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: 3docSec

Also found by: R-Nemes, Vagner, auditsea, hassan-truscova, n1punp, nadin

Labels

bug
3 (High Risk)
satisfactory
duplicate-58

Awards

482.4792 USDC - $482.48

External Links

Lines of code

https://github.com/code-423n4/2023-08-goodentry/blob/71c0c0eca8af957202ccdbf5ce2f2a514ffe2e24/contracts/TokenisableRange.sol#L333-L339

Vulnerability details

Impact

In TokenisableRange -> returnExpectedBalanceWithoutFees function, sqrtPriceX96 is calculated using prices of two tokens, but the calculation overflows which will result in the transaction revert.

Proof of Concept

(amt0, amt1) = LiquidityAmounts.getAmountsForLiquidity( uint160( sqrt( (2 ** 192 * ((TOKEN0_PRICE * 10 ** TOKEN1.decimals) / TOKEN1_PRICE)) / ( 10 ** TOKEN0.decimals ) ) ), TickMath.getSqrtRatioAtTick(lowerTick), TickMath.getSqrtRatioAtTick(upperTick),  liquidity);

(2 ** 192 * ((TOKEN0_PRICE * 10 ** TOKEN1.decimals) / TOKEN1_PRICE)) is calculated at once, assuming token1's decimal is 18, 2^192 * 10^18 ~ 2^252, it means when token0 price is more than 16x of token1 price, it will overflow causing revert.

Tools Used

Manual Review

Mitigation Steps

Do not put whole 2^192 in the calculation but just put 10^18 or whatever smaller number and then deal with remaining number outside of sqrt.

Assessed type

Math

#0 - c4-pre-sort

2023-08-09T16:29:09Z

141345 marked the issue as duplicate of #162

#1 - c4-pre-sort

2023-08-10T13:49:00Z

141345 marked the issue as not a duplicate

#2 - c4-pre-sort

2023-08-10T13:49:08Z

141345 marked the issue as duplicate of #58

#3 - c4-judge

2023-08-20T17:30:22Z

gzeon-c4 marked the issue as satisfactory

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