Skip to content
Business logic Audit finding Intermediate

If an airdrop happens before a mint the price could skyrocket

The price calculation for a periodic NFT sale (salesOption 3) includes all NFTs in circulation, including those from an airdrop. If an airdrop occurs before the sale, the starting price is inflated, causing whitelisted users to pay more than intended.

0x3b Follow with AvantGard and lanrebayode77

Originally disclosed on Code4rena

Submitted by 0x3b, also found by AvantGard and lanrebayode77

As explained by the docs, several steps can occur during the minting process. However, an airdrop before salesOption 3 can lead to price inflation.

Proof of Concept

Under salesOption 3, getPrice returns:

return collectionPhases[_collectionId].collectionMintCost
                    + ((collectionPhases[_collectionId].collectionMintCost / collectionPhases[_collectionId].rate) * gencore.viewCirSupply(_collectionId));

This is the increased rate based on the NFTs already in circulation. If an airdrop occurs before a mint with salesOption 3, the price will be much higher than intended.

Example:

Steps | Option | NFTs | Price | Rate |

1 OG users | Airdropped | 20 NFTs | free | - |

2 Whitelisted | Sales 3 | 10 NFTs | 1 ETH | 10 (0.1 ETH increase) |

3 Public | Sales 1 | 70 NFTs | 2 ETH | - |

With the current three steps, after the airdrop, salesOption 3 should start at 1 ETH and gradually increase to 2 ETH. Afterward, it should mint at a constant rate of 2 ETH.

However, when sales option 3 starts, getPrice will return 3 ETH instead of 1 ETH. This will cause the initial users to pay an inflated price, which was not intended by the owner and can harm their reputation. It’s also unfair to the users, as these so-called special (whitelisted) users will pay increased prices.

Note: see original submission for math breakdown provided.

POC

Gist here.

Add to remappings - contracts/=smart-contracts/ and run it with forge test --match-test test_airdrop --lib-paths ../smart-contracts.

Recommended Mitigation Steps

You can implement a mapping with the airdropped NFTs and deduct this value from gencore.viewCirSupply(_collectionId) to avoid disrupting the minting process.

Assessed type

Error

a2rocket (NextGen) confirmed via duplicate issue #246

0xsomeone (judge) commented:

After further consideration, I have decided to merge several periodic mint-related findings into two separate categories:

  • Incorrect Price Calculations (#381)
  • Incorrect Enforcement of Periodic Mint Limitations (#380)

The reasoning behind this change is that both rely on different aspects of the code and have different root causes. The former highlights a flaw in the getPrice function and how it calculates prices, whilst the latter highlights a flaw in the mint function and how it calculates the lastMintDate. Fixing one does not infer that the other is fixed, reinforcing the idea that they are separate vulnerabilities.

I consider this submission to be of a lower severity than #380, correctly given that it can be rectified. Specifically, a lastMintDate update in the future per #2012 cannot be reversed, while an incorrect price as indicated in this and relevant submissions can be reversed by reconfiguring the collection and can be controlled by the user simply not willing to pay the inflated price until the price is corrected.

A problem when selecting the best report in this submission is that all Warden submissions make mention of “airdropped” tokens and fail to identify that the general circulating supply affects the price in their proposed remediation, such as #380. I have thus chosen this report as the best given that it cites the relevant documentation, contains a privately accessible valid PoC, and provides a basic representation of the pricing formula using mathematical notation to illustrate the problem.

MrPotatoMagic (warden) commented:

@0xsomeone, here is why I believe this issue (and its duplicates) should be marked as a duplicate of #380 but with a partial grading.

  1. The root cause is the same, i.e. existing circulating supply causes sale model 3 to work incorrectly.
  2. The impact mentioned here and that in #380 are two sides of the same coin.
  3. The issue mentions that prices will skyrocket (which is true) but the issue also mentions that initial users to pay an inflated price, which is incorrect since the user cannot mint (pay) in the first place due to the lastMintDate being set to a date far ahead in the future.
  4. I mention partial grading because although the root cause is correct, the impact demonstrated is invalid. Thus, according to the C4 final SC verdict in the docs, the issue should deserve a partial-grading, while being marked as a dup of #380 due to the root cause being the same.

0xsomeone (judge) commented:

@MrPotatoMagic, thanks for contributing! The root cause is not the presence of the circulating supply, it is the incorrect price calculation of a sale model 3. While it may make sense to carry over sale model 3 sales across different periods, it does not make sense to carry over mint restrictions. For example:

  • Collection A runs a periodic sale, amassing 10 NFTs sold, and reaching a price of 10 ETH per NFT.
  • Collection A performs an airdrop as part of an incentive program.
  • Collection A opens up the periodic sale for a public run, wanting to maintain the 10 ETH per NFT price.

To fix this:

  • Issue 381 would need to update its price calculation to use solely the circulating supply minted via the periodic sale.
  • Issue 380 would need to reset its lastMintDate entirely.

A fix for #380 does not fix #381 and vice versa. Both concern different parts of the code and require different alleviations.

Based on the above, I will maintain these submissions as separate.


The original report as published on Code4rena, by 0x3b. 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

The price calculation for salesOption 3 uses the total circulating supply, which includes airdropped NFTs, instead of only those minted through the sale.

Impact

Whitelisted users could pay an inflated price for NFTs, which may harm the project's reputation and is unfair to those users.

What the attacker needed

Airdrop occurs before salesOption 3 mint; salesOption 3 is used

The fix

The price calculation should exclude airdropped NFTs by tracking them separately and deducting their count from the circulating supply used in the formula.

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.

In some NFT sales, the price goes up as more items are sold. The code calculates the price based on how many NFTs already exist. If the project gives away free NFTs (an airdrop) before the paid sale starts, the code thinks many have been sold and sets a higher starting price. So people in the paid sale pay more than they should.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0x3b

View all

23 more disclosed reports, best first.

More from NextGen

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.