Skip to content
Business logic Audit finding Intermediate

Multiple mints can brick any form of salesOption 3 mintings

0x3b Follow with AvantGard, MrPotatoMagic and 7 others

Originally disclosed on Code4rena

Submitted by 0x3b, also found by AvantGard, MrPotatoMagic, Krace (1, 2), ZdravkoHr, 0xlemon, fibonacci, nuthan2x, trachev, oakcobalt, and Noro

As explained by the sponsor, some collections might want to conduct multiple mints on different days. However, due to the way salesOption 3 works, these multiple mints might encounter issues.

Proof of Concept

A collection has completed its first mint, where it minted 500 NFTs. However, the collection consists of 1000 NFTs, so the owner plans to schedule another mint, this time using sales option 3.

Values | Time |

allowlistStartTime | 4 PM |

allowlistEndTime | 7 PM |

publicStartTime | 7 PM |

publicEndTime | 1 day after public start |

timePeriod | 1 min |

The first user’s mint will proceed smoothly since timeOfLastMint falls within the previous mint period. However, the second user’s mint will fail. The same applies to all other whitelisted users. This issue arises due to the following block:

lastMintDate[col] = collectionPhases[col].allowlistStartTime
                + (collectionPhases[col].timePeriod * (gencore.viewCirSupply(col) - 1));

This calculation extends the allowed time significantly, granting the second minter an allowed time of allowlistStartTime + 1 min * (500-1) = allowlistStartTime + 499 min, which is equivalent to 8 hours and 19 minutes after allowlistStartTime. This enables the second user to mint at 12:19 AM, long after the whitelist has ended and in the middle of the public sale. And if anyone tries to mint, this call will revert with underflow error, as timeOfLastMint > block.timestamp.

uint256 tDiff = (block.timestamp - timeOfLastMint) / collectionPhases[col].timePeriod;

It’s worth noting that some collections may disrupt the whitelist, while others could brick the entire mint process; especially if there are more minted NFTs or a longer minting period.

POC

  1. Gits - https://gist.github.com/0x3b33/677f86f30603dfa213541cf764bbc0e8.
  2. Add to remappings - contracts/=smart-contracts/.
  3. Run it with forge test --match-test test_multipleMints --lib-paths ../smart-contracts.

Recommended Mitigation Steps

For this fix, I am unable to give any suggestion as big parts of the protocol need to be redone. I can only point out the root cause of the problem, which is (gencore.viewCirSupply(col) - 1) in the snippet below.

lastMintDate[col] = collectionPhases[col].allowlistStartTime + (collectionPhases[col].timePeriod * (gencore.viewCirSupply(col) - 1));

Assessed type

Error

a2rocket (NextGen) confirmed

0xsomeone (judge) increased severity to High and commented:

The Warden’s submission was selected as the best given that it illustrates the problem by citing the relevant documentation of the project, contains a valid PoC, and acknowledges the difficulty in rectifying this issue. While the submission has under-estimated the issue’s severity, the relevant high-severity issues (#2012, #1123, #939, #632, #631, #89) were not of sufficient quality and the best candidate (#1123) minimizes the issue’s applicability and does not advise a proper recommendation either.

To alleviate the issue, the Sponsor is advised to implement a “start date” for the periodic sales that is reconfigured whenever a periodic sale is re-instated. This would permit the lastMintDate calculations to “restart” the date from which periodic sale allowances should be tracked and also allow the code to snapshot the circulating supply at the time the first periodic sale occurs of each independent periodic sale phase. As the Warden correctly assessed, a viable solution to this vulnerability is difficult to implement.


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.

What is known

A high-severity business logic bug in NextGen. Code4rena made it public on 8 January 2024. Found in the 2023-10-nextgen audit contest (finding H-04), also found by 9 other wardens.

About Business logic

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

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

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.