Float Capital contest - loop's results

Synthetic assets made simple. No overcollateralization. No liquidation. Not a fork.

General Information

Platform: Code4rena

Start Date: 05/08/2021

Pot Size: $50,000 USDC

Total HM: 9

Participants: 16

Period: 7 days

Judge: 0xean

Total Solo HM: 4

Id: 22

League: ETH

Float Capital

Findings Distribution

Researcher Performance

Rank: 13/16

Findings: 2

Award: $491.06

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: gpersoon

Also found by: 0xImpostor, hack3r-0m, jonah1005, loop, pauliax, shw

Labels

bug
duplicate
2 (Med Risk)
sponsor confirmed
resolved

Awards

139.9465 USDC - $139.95

External Links

Handle

loop

Vulnerability details

Impact

Multiple markets can be created before being initialized since createNewSyntheticMarket and initializeMarket are separate functions. The SyntheticTokens used in initialization will however always be those of the latest market created.

Proof of Concept

Let's create two synthetic markets using the createNewSyntheticMarket function, first TokenA then TokenB, without invoking initializeMarket inbetween market creation. The global variable latestMarket will have been increased by 2 now, correctly pointing to TokenB as the latest market. The synthetic tokens used for the market will also be created during this function.

When trying to initialize the market for TokenA using the initializeMarket function, the staker funds that will be added are those of the latestMarket (the synthetic tokens for TokenB). The same goes for the minting of the synthetic tokens in _seedMarketInitially. As a result it is not possible to initialize the market for TokenA anymore since it is not the latest market.

A potential issue might also arise for adding staking funds when the marketIndex used in initializeMarket is smaller than the value of latestMarket. The marketIndex given to addNewStakingFund is that of latestMarket. This might result in staking funds being created for a marketIndex at a higher value. Since addNewStakingFunds does not set marketExists for that specific marketIndex to true, if tokenB now gets initialized at the same marketIndex as latestMarket, it will now overwrite the previously initialized staking funds.

Tools Used

Editor

Make sure a market gets initialized before creating a new one.

#0 - JasoonS

2021-08-11T05:22:07Z

This is somewhat a duplicate of #9 - but kind of misses some of the nuance?

The mitigation isn't possible, our initialize function needs to be separate due to gas limits (deploying two custom erc20 tokens is expensive gas wise!)

Mitigation in other issue is correct.

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