QuickSwap and StellaSwap contest - rvierdiiev's results

A concentrated liquidity DEX with dynamic fees.

General Information

Platform: Code4rena

Start Date: 26/09/2022

Pot Size: $50,000 USDC

Total HM: 13

Participants: 113

Period: 5 days

Judge: 0xean

Total Solo HM: 6

Id: 166

League: ETH

QuickSwap and StellaSwap

Findings Distribution

Researcher Performance

Rank: 32/113

Findings: 2

Award: $87.52

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

35.4829 USDC - $35.48

Labels

bug
duplicate
2 (Med Risk)

External Links

Lines of code

https://github.com/code-423n4/2022-09-quickswap/blob/main/src/core/contracts/AlgebraPool.sol#L193-L206

Vulnerability details

Impact

AlgebraPool.initialize is called to initialize pool with initial price.

It can be only called once, but it can be called by anyone.

Suppose that someone created new pool for USDT:USDC tokens by calling AlgebraFactory.createPool and wants to set price 1:1. Factory at this point has created new pool, but it is not initialized with initial price yet.

Now anyone can initialize that pair with any price by calling AlgebraPool.initialize. For example for USDT:USDC pair someone provided price 1:20. So as a result we have the pool initialized not in the way that creator wanted.

Proof of Concept

This test can be run in AlgebraPool.spec.ts file. It shows that after the pool is created, another account can initialize it with initial price.

it('initialized by anyone', async () => { const initPrice = encodePriceSqrt(1, 25) await pool.connect(other).initialize(initPrice) const { price, timepointIndex } = await pool.globalState() expect(price).to.eq(price) expect(timepointIndex).to.eq(0) expect((await pool.globalState()).tick).to.eq(-32191) })

Tools Used

Let creator of the pool to provide initial price at the pool creating and call AlgebraPool.initialize inside AlgebraFactory.createPool.

#0 - 0xean

2022-10-14T12:17:26Z

dupe of #84

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