Caviar Private Pools - SaeedAlipoor01988's results

A fully on-chain NFT AMM that allows you to trade every NFT in a collection.

General Information

Platform: Code4rena

Start Date: 07/04/2023

Pot Size: $47,000 USDC

Total HM: 20

Participants: 120

Period: 6 days

Judge: GalloDaSballo

Total Solo HM: 4

Id: 230

League: ETH

Caviar

Findings Distribution

Researcher Performance

Rank: 84/120

Findings: 1

Award: $23.08

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

23.0813 USDC - $23.08

Labels

bug
3 (High Risk)
satisfactory
upgraded by judge
duplicate-167

External Links

Lines of code

https://github.com/code-423n4/2023-04-caviar/blob/cd8a92667bcb6657f70657183769c244d04c015c/src/PrivatePool.sol#L230 https://github.com/code-423n4/2023-04-caviar/blob/cd8a92667bcb6657f70657183769c244d04c015c/src/PrivatePool.sol#L231

Vulnerability details

Impact

Check PoC please.

Proof of Concept

It casts netInputAmount - feeAmount - protocolFeeAmount, which is a uint256, to a uint128. If netInputAmount - feeAmount - protocolFeeAmount is larger than 2 ** 128 - 1, the unsafe cast will only keep its rightmost bits, causing the result to be much smaller.

// update the virtual reserves virtualBaseTokenReserves += uint128(netInputAmount - feeAmount - protocolFeeAmount); virtualNftReserves -= uint128(weightSum);

The same is happening for weightSum,

// calculate the sum of weights of the NFTs to buy uint256 weightSum = sumWeightsAndValidateProof(tokenIds, tokenWeights, proof);

If sumWeightsAndValidateProof(tokenIds, tokenWeights, proof) is larger than 2 ** 128 - 1, the unsafe cast will only keep its rightmost bits.

Tools Used

Manually

use OpenZeppelin’s SafeCast library when casting from uint256 to uint128.

#0 - c4-pre-sort

2023-04-20T18:04:57Z

0xSorryNotSorry marked the issue as duplicate of #625

#1 - c4-judge

2023-04-27T08:54:15Z

GalloDaSballo marked the issue as duplicate of #167

#2 - c4-judge

2023-05-02T07:55:16Z

GalloDaSballo changed the severity to 3 (High Risk)

#3 - c4-judge

2023-05-02T07:56:09Z

GalloDaSballo 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