Tracer contest - 0xsanson's results

Build and trade with Tracer’s Perpetual Swaps and gain leveraged exposure to any market in the world.

General Information

Platform: Code4rena

Start Date: 24/06/2021

Pot Size: $80,000 USDC

Total HM: 18

Participants: 12

Period: 7 days

Judge: cemozer

Total Solo HM: 11

Id: 16

League: ETH

Tracer

Findings Distribution

Researcher Performance

Rank: 4/12

Findings: 4

Award: $10,396.42

🌟 Selected for report: 4

πŸš€ Solo Findings: 1

Findings Information

🌟 Selected for report: 0xsanson

Also found by: shw

Labels

bug
3 (High Risk)
sponsor confirmed

Awards

3019.5792 USDC - $3,019.58

External Links

Handle

0xsanson

Vulnerability details

Impact

In the Pricing contract, an agent can manipulate the trading prices by spamming an high amount of trades.

Indeed an agent can create an high amount of orders at an arbitrary price and with a near-zero amount (so the agent doesn't even need large funds); next he/she pairs the orders with another account and calls Trader.executeTrade; now every order calls a Pricing.recordTrade using the arbitrary price set by the agent.

Since the trades are all made in the same hour, by the way hourlyTracerPrices[currentHour] is calculated, it skews the average price towards the price set by the agent. This arbitrary value is used to calculate the fundingRates and the fairPrice, letting a malicious agent get the ability to manipulate the market.

Proof of Concept

https://github.com/code-423n4/2021-06-tracer/blob/main/src/contracts/Pricing.sol#L129

Tools Used

Manual analysis

Pass the fillAmount parameter to recordTrade(...), and calculate hourlyTracerPrices[currentHour].trades summing fillAmount instead of 1 every trade.

#0 - raymogg

2021-07-05T03:03:03Z

Issue is valid, and there appear to be a few other issues that reference similar problems.

The Trader contract will have a whitelist allowing only select relayers to push orders on chain. As long as off chain order books have sufficient liquidity, this issue is then mitigated as users can't just arbitrarily match orders and send them in, they must be matched on a book with liquidity. To alter the price you would then need to eat through significant liquidity (increasing the cost of this attack).

Findings Information

🌟 Selected for report: 0xsanson

Labels

bug
3 (High Risk)
sponsor confirmed

Awards

6710.1761 USDC - $6,710.18

External Links

Handle

0xsanson

Vulnerability details

Impact

In LibBalances.applyTrade() we need to collect a fee from the trade. The current code however subtracts a fee from the short position and adds it to the long. The correct implementation is to subtract a fee to both (see TracerPerpetualSwaps.sol#L272). This issue causes withdrawals problems, since Tracer thinks it can withdraw the collect fees, leaving the users with an incorrect amount of quote tokens.

Proof of Concept

https://github.com/code-423n4/2021-06-tracer/blob/main/src/contracts/lib/LibBalances.sol#L187

Tools Used

Manual analysis

Change +fee to -fee in the highlighted line.

#0 - raymogg

2021-07-05T04:36:05Z

Valid issue πŸ‘

#1 - kumar-ish

2021-07-15T12:58:54Z

(Accidentally closed)

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