Canto Dex Oracle contest - Jeiwan's results

Execution layer for original work.

General Information

Platform: Code4rena

Start Date: 07/09/2022

Pot Size: $20,000 CANTO

Total HM: 7

Participants: 65

Period: 1 day

Judge: 0xean

Total Solo HM: 3

Id: 159

League: ETH

Canto

Findings Distribution

Researcher Performance

Rank: 8/65

Findings: 3

Award: $357.08

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: hickuphh3

Also found by: 0xNazgul, 0xSky, CertoraInc, Deivitto, Jeiwan, SinceJuly, hansfriese, linmiaomiao, rbserver

Labels

bug
duplicate
2 (Med Risk)

Awards

664.9949 CANTO - $107.40

External Links

Lines of code

https://github.com/code-423n4/2022-09-canto/blob/main/src/Swap/BaseV1-periphery.sol#L582

Vulnerability details

Impact

Token 0 TVL can be lower than it in fact is due to loss of precision when calculating it. This will make the LP token price lower than it actually is.

Proof of Concept

Solidity supports only integer division: when dividing two numbers the result is truncated, e.g.:

10.9999999999 ether / 1 ether = 10 ether

When calculating token0TVL:

uint token0TVL = assetReserves[i] * (prices[i] / decimals);

A price gets divided by decimals before being multiplied by an asset reserves. The division will result in a truncated number, which will make the result of the multiplication smaller.

Tools Used

Consider ordering multiplication before division:

uint token0TVL = (assetReserves[i] * prices[i]) / decimals;

#0 - nivasan1

2022-09-10T17:13:06Z

duplicate #106

#1 - 0xean

2022-10-13T13:39:00Z

dupe of #41

Findings Information

🌟 Selected for report: Chom

Also found by: 0xSmartContract, Jeiwan, SinceJuly, V_B, cccz, linmiaomiao

Labels

bug
duplicate
2 (Med Risk)

Awards

1303.145 CANTO - $210.46

External Links

Lines of code

https://github.com/code-423n4/2022-09-canto/blob/main/src/Swap/BaseV1-periphery.sol#L491 https://github.com/code-423n4/2022-09-canto/blob/main/src/Swap/BaseV1-periphery.sol#L498 https://github.com/code-423n4/2022-09-canto/blob/main/src/Swap/BaseV1-periphery.sol#L501 https://github.com/code-423n4/2022-09-canto/blob/main/src/Swap/BaseV1-periphery.sol#L505

Vulnerability details

Impact

Malicious actors can deploy fake tokens with one of the hard coded token symbols. The getUnderlyingPrice function will return the price of the original token when a fake token is passed as the parameter.

Proof of Concept

Since symbols don't unique identify tokens (a token can have any symbol, including one belonging to an existing token), there's possibility that a fake token with one of the symbols checked in the getUnderlyingPrice function is deployed. The function getUnderlyingPrice will then return a price of the real token when a fake token is provided.

Exploit scenario

Someone deploys a fake token with symbol "cCANTO". A protocol that's integrated with Canto (or Canto itself) calls getUnderlyingPrice to get the price of the fake token. The price of the real cCANTO is returned instead, which allows a malicious actor to use the fake token as a collateral or in another market operation.

Tools Used

Consider using token addresses to identify tokens. As an example, this is how a similar function is implemented in the UniswapV2 Anchored View used by Compound:

#0 - nivasan1

2022-09-10T17:20:35Z

duplicate #24

[Q01] Unused assignment

Targets:

Description

Due to the early return in the next line, the assignment to underlying is not used.

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