Skip to content
Smart contracts Audit finding Advanced

The variable fShareRatio is vulnerable to manipulation by flash minting and burning

The fShareRatio variable in the purchaseMembership function can be manipulated by flash minting and burning FSD tokens, potentially allowing a user to purchase membership when the ratio is below 100% or to earn more staking rewards. However, a 3.5% tribute fee makes such manipulation unprofitable, and the project confirmed the example is not possible.

FairSide contest

Originally disclosed on Code4rena

The variable fShareRatio in the function purchaseMembership of contract FSDNetwork is vulnerable to manipulation by flash minting and burning, which could affect several critical logics, such as the check of enough capital in the pool (line 139-142) and the staking rewards (line 179-182).

The fShareRatio is calculated (line 136) by:

(fsd.getReserveBalance() - totalOpenRequests).mul(1 ether) / fShare;

Where fsd.getReserveBalance() can be significantly increased by a user minting a large amount of FSD tokens with flash loans. In that case, the increased fShareRatio could affect the function purchaseMembership results. For Example, the user could purchase the membership even if the fShareRatio is < 100% previously, or the user could earn more staking rewards than before to reduce the membership fees. Although performing flash minting and burning might not be profitable overall since a 3.5% tribute fee is required when burning FSD tokens, it is still important to be aware of the possible manipulation of fShareRatio.

Recommend forcing users to wait for (at least) a block to prevent flash minting and burning.

fairside-core (FairSide) confirmed:

I believe this to be a minor (1) or none (0) severity issue given that the manipulation of fShareRatio is unsustainable due to the fee, and the Example given is actually not possible. Suppose I affect fShareRatio to go above 100% to purchase a membership. In that case, I will be unable to burn the necessary FSD to go below 100% again as burning is disabled when the ratio is or would go to below 100%.

fairside-core (FairSide) resolved:

Fixed in PR#2.

cemozerr (Judge) commented:

Labeling this as low risk as a 3.5% tribute fee makes it very unlikely that these flash minting will be profitable.

The original report as published on Code4rena. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the fShareRatio is calculated from a token balance that can be temporarily inflated via flash minting, without any time delay.

Impact

The manipulation could affect membership purchase and staking rewards, but a 3.5% tribute fee makes it unprofitable and the project states the example is not possible.

What the attacker needed

Flash loan capability; pay 3.5% tribute fee

The fix

The issue was fixed in PR#2, likely by forcing users to wait at least a block to prevent flash minting and burning.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract uses a ratio to decide if you can buy a membership and how much reward you get. An attacker could temporarily create a lot of tokens to change that ratio, but doing so costs a fee, so it is not worth it.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More from FairSide contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.