Tigris Trade contest - yjrwkk's results

A multi-chain decentralized leveraged exchange featuring instant settlement and guaranteed price execution on 30+ pairs.

General Information

Platform: Code4rena

Start Date: 09/12/2022

Pot Size: $90,500 USDC

Total HM: 35

Participants: 84

Period: 7 days

Judge: GalloDaSballo

Total Solo HM: 12

Id: 192

League: ETH

Tigris Trade

Findings Distribution

Researcher Performance

Rank: 66/84

Findings: 2

Award: $19.04

🌟 Selected for report: 1

🚀 Solo Findings: 0

Awards

1.1472 USDC - $1.15

Labels

bug
2 (Med Risk)
satisfactory
duplicate-377

External Links

Lines of code

https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L943-L969

Vulnerability details

Impact

Users have to put a lot of trust in the owner, which should not be the case in a web3 application.

They might not want to use the platform knowing about such a risk.

Proof of Concept

In Trading.sol#L943-L969 the owner may at any time update the close fees for already open positions to values unacceptable for the traders, essentially stealing their funds.

Tools Used

Visual Studio Code

Consider refactoring the code, so that the platform users know all the fees before placing a position, and setFees affects only new orders.

#0 - c4-judge

2022-12-23T17:56:32Z

GalloDaSballo marked the issue as duplicate of #514

#1 - c4-judge

2023-01-22T13:48:26Z

GalloDaSballo marked the issue as duplicate of #377

#2 - c4-judge

2023-01-22T17:35:07Z

GalloDaSballo marked the issue as satisfactory

Awards

17.8851 USDC - $17.89

Labels

bug
2 (Med Risk)
primary issue
selected for report
sponsor acknowledged
M-19

External Links

Lines of code

https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L650 https://github.com/code-423n4/2022-12-tigris/blob/main/contracts/Trading.sol#L675

Vulnerability details

Impact

In Trading.sol a deposit or withdrawal of tokens with decimals higher than 18 will always revert.

This is the case e.g. for NEAR which is divisible into 10e24 yocto

Proof of Concept

Change 00.Mocks.js#L33 to:

args: ["USDC", "USDC", 24, deployer, ethers.utils.parseUnits("1000", 24)]

Then in 07.Trading.js:

Opening and closing a position with tigUSD output Opening and closing a position with <18 decimal token output

are going to fail with:

Error: VM Exception while processing transaction: reverted with panic code 0x11 (Arithmetic operation underflowed or overflowed outside of an unchecked block)

Tools Used

Visual Studio Code

Update calculations in the contract to account for tokens with decimals higher than 18.

#0 - GalloDaSballo

2022-12-20T15:42:38Z

Best because it has a simple POC and is concise

#1 - c4-judge

2022-12-20T15:42:42Z

GalloDaSballo marked the issue as primary issue

#2 - TriHaz

2023-01-09T17:23:03Z

We are aware of that, we are not planning on adding any token that has more than 18 dec.

#3 - c4-sponsor

2023-01-09T17:23:10Z

TriHaz marked the issue as sponsor acknowledged

#4 - GalloDaSballo

2023-01-13T18:55:39Z

The Warden has shown how, due to an underflow, the system in-scope can revert when using tokens with more than 18 decimals.

Because of how scope was defined, I believe the finding to be valid, I believe a nofix is acceptable as long as the sponsor keeps in mind this risk.

Because of the risk shown, I agree with Medium Severity

#5 - c4-judge

2023-01-13T18:56:13Z

GalloDaSballo marked the issue as selected for report

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