Caviar Private Pools - Naubit'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: 116/120

Findings: 1

Award: $5.98

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

5.9827 USDC - $5.98

Labels

bug
2 (Med Risk)
satisfactory
edited-by-warden
duplicate-858

External Links

Lines of code

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

Vulnerability details

Impact

In the change() function at https://github.com/code-423n4/2023-04-caviar/blob/cd8a92667bcb6657f70657183769c244d04c015c/src/PrivatePool.sol#L733, which is used to allow the caller to change a set of NFTs that the caller owns for another set of NFTs in the pool; there is a line where the contract calculates the fee and protocol fee amounts for those NFTs being changed.

This function will fail, causing a revert of the change() function (and then causing a revert of the change() function in theEthRouter file (https://github.com/code-423n4/2023-04-caviar/blob/cd8a92667bcb6657f70657183769c244d04c015c/src/EthRouter.sol#L273) when the baseToken decimals are less than 4, as explained in the "Proof of Concept" section.

Proof of Concept

When calling the function changeFeeQuote to calculate the feeAmount and protocolFeeAmount vars of a change in a private pool, if the base token set in the private pool has 3 decimals or less, the subtraction performed at https://github.com/code-423n4/2023-04-caviar/blob/cd8a92667bcb6657f70657183769c244d04c015c/src/PrivatePool.sol#L733 will fail.

In Solidity 0.8.19 (the version used by the contract) it will revert the operation so we won't be able to calculate those fees, causing that we won't be able to change NFTs in the pool.

Tools Used

VS Code

Before trying to do the subtraction, it should verify the baseToken has at least 4 decimals. In case it has less, it would need to adjust the subtraction value before calculating it.

#0 - c4-pre-sort

2023-04-20T15:22:56Z

0xSorryNotSorry marked the issue as duplicate of #858

#1 - c4-judge

2023-05-01T07:14:49Z

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