Panoptic - sammy's results

Permissionless, perpetual options trading on any token, any strike, any size.

General Information

Platform: Code4rena

Start Date: 01/04/2024

Pot Size: $120,000 USDC

Total HM: 11

Participants: 55

Period: 21 days

Judge: Picodes

Total Solo HM: 6

Id: 354

League: ETH

Panoptic

Findings Distribution

Researcher Performance

Rank: 20/55

Findings: 2

Award: $648.15

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: DadeKuma

Also found by: Bauchibred, Dup1337, Vancelot, jesjupyter, sammy

Labels

bug
2 (Med Risk)
downgraded by judge
satisfactory
edited-by-warden
:robot:_64_group
duplicate-537

Awards

615.1933 USDC - $615.19

External Links

Lines of code

https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/PanopticFactory.sol#L341

Vulnerability details

The creation of a pool requires the creator to mint full-range liquidity into the corresponding Uniswap V3 pool. However, this fullRangeLiquidity is calculated using the slot0 SqrtPriceX96 from the Uniswap pool, which is susceptible to manipulation.

Impact

MEV bots can utilize flash loans to front-run the creation of a pool, thereby increasing the costs for the user. The user may end up paying more token0 and token1 than necessary for creating the pool. Subsequently, these bots may execute trades that profit from the inflated prices after the pool's creation.

Proof of Concept

Tools Used

Manual Review

Implement the use of TWAP (Time-Weighted Average Price) instead.

Assessed type

MEV

#0 - c4-judge

2024-04-24T19:10:26Z

Picodes marked the issue as duplicate of #562

#1 - c4-judge

2024-05-06T15:55:26Z

Picodes marked the issue as unsatisfactory: Invalid

#2 - sammy-tm

2024-05-10T14:28:37Z

@Picodes Can you please take a look, this is a dup of #537

#3 - c4-judge

2024-05-10T14:30:29Z

Picodes marked the issue as not a duplicate

#4 - c4-judge

2024-05-10T14:30:38Z

Picodes marked the issue as duplicate of #537

#5 - c4-judge

2024-05-10T14:30:42Z

Picodes marked the issue as satisfactory

#6 - c4-judge

2024-05-13T14:24:20Z

Picodes changed the severity to 2 (Med Risk)

Awards

32.9585 USDC - $32.96

Labels

bug
downgraded by judge
grade-b
QA (Quality Assurance)
satisfactory
sponsor disputed
:robot:_61_group
duplicate-501
Q-23

External Links

Lines of code

https://github.com/code-423n4/2024-04-panoptic/blob/833312ebd600665b577fbd9c03ffa0daf250ed24/contracts/CollateralTracker.sol#L446

Vulnerability details

The calculation of the maximum shares received for a deposit in CollateralTracker.sol is incorrect.

In the mint() function, the assets received for a mint are being calculated using the previewMint() function, which has a mismatch with the current maxMint() function in the scenario in which the max possible assets are being deposited for the mint.

Impact

Detailed description of the impact of this finding.

Proof of Concept

Currently the maxMint() function calculates the max shares as follows :

maxShares = (((type(uint104).max)*totalSupply()/totalAssets())*DECIMALS)/(DECIMALS+COMMISSION_FEE)

and previewMint() calculates the assets received as :

assets = (shares*DECIMALS*totalAssets())/(totalSupply*(DECIMALS-COMISSION_FEE)) In the max mint scenario, let's assume the assets required are maximum, i.e, type(uint104).max : type(uint104).max = (maxShares*DECIMALS*totalAssets())/(totalSupply*(DECIMALS-COMISSION_FEE)) Simplifying, we get : maxShares = (type(uint104).ma0x)*totalSupply*(DECIMALS-COMISSION_FEE)/DECIMALS*totalAssets()

The derived formula does not match the formula used in maxMint() leading to incorrect calculation of shares.

Tools Used

Manual Review

-            return (convertToShares(type(uint104).max) * DECIMALS) / (DECIMALS + COMMISSION_FEE);
+            return (convertToShares(type(uint104).max) * (DECIMALS - COMMISSION_FEE)) / DECIMALS;


## Assessed type

Error

#0 - c4-judge

2024-04-25T20:47:53Z

Picodes marked the issue as duplicate of #553

#1 - c4-judge

2024-04-25T20:48:31Z

Picodes marked the issue as not a duplicate

#2 - c4-judge

2024-04-25T20:48:34Z

Picodes marked the issue as primary issue

#3 - dyedm1

2024-04-29T14:07:33Z

actually is dup #553 , conf'd there

#4 - c4-judge

2024-04-29T21:38:02Z

Picodes marked the issue as duplicate of #553

#5 - c4-judge

2024-04-29T21:41:30Z

Picodes marked the issue as satisfactory

#6 - c4-judge

2024-05-09T19:15:20Z

Picodes changed the severity to QA (Quality Assurance)

#7 - c4-judge

2024-05-10T00:08:59Z

Picodes marked the issue as grade-b

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