DeFiFoundry
20,000 USDC
View results
Submission Details
Severity: high
Invalid

Disproportionate token distribution due to extreme bid-to-token ratio

Summary

When the total amount of bids (totalBids) is extremely small compared to the total number of tokens being auctioned (totalTokens), the contract's distribution algorithm can lead to severely skewed and unfair token allocations. This issue arises from the method used to calculate the 'multiplier' variable, which determines how many auction tokens each bidder receives per FjordPoint bid.

Vulnerability Details

The vulnerability stems from the following calculation in the auctionEnd() function:

multiplier = totalTokens.mul(PRECISION_18).div(totalBids);

https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordAuction.sol#L197C9-L197C67

When totalBids is very small, this results in an extremely large multiplier. Subsequently, in the claimTokens() function, this large multiplier is used to calculate each bidder's token allocation:

uint256 claimable = userBids.mul(multiplier).div(PRECISION_18);

https://github.com/Cyfrin/2024-08-fjord/blob/0312fa9dca29fa7ed9fc432fdcd05545b736575d/src/FjordAuction.sol#L217C8-L217C72

Here's a practical example:

Consider an auction with the following parameters:

  • totalTokens = 100,000,000 (100 million)

  • PRECISION_18 = 1e18 (1 followed by 18 zeros)

  • totalBids = 1 (just 1 FjordPoint bid in total)

In this scenario:

Multiplier calculation would be:

multiplier = totalTokens * PRECISION_18 / totalBids
= 100,000,000 * 1e18 / 1
= 1e26 (100 followed by 24 zeros)

Now, let's say a user who bid 1 FjordPoint tries to claim their tokens:

claimable = 1 * 1e26 / 1e18
= 1e8
= 100,000,000

In this case, the single bidder would receive all 100 million tokens. This is mathematically correct given the inputs, but it might not be the intended outcome of the auction.

Impact

A user with a very small bid can take all the auction tokens.

Tools Used

Manual review

Recommendations

Implement checks to ensure a more equitable distribution even with very low total bids.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Design choice

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.