Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No sanitiy check on allowlist and public phases, potential fixed price for salesOption == 2 #515

Closed
c4-submissions opened this issue Nov 7, 2023 · 5 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-c QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-submissions
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-10-nextgen/blob/8b518196629faa37eae39736837b24926fd3c07c/smart-contracts/MinterContract.sol#L540

Vulnerability details

Impact

In the case where collectionPhasesDataStructure.allowlistEndTime is set to a value higher than collectionPhasesDataStructure.publicEndTime, the getPrice function will return collectionPhasesDataStructure.collectionMintCost instead of the adjusted decreasing price, resulting in an excessive cost for the NFT minter.

Proof of Concept

The documentation indicates that sales models can be combined with phased allowlists to execute highly complex drops. This includes phases with one or several optional allowlist sales, as well as optional public sales.
Given the flexibility of the contract, to avoid a public sale, setCollectionPhases should be fed with _publicStartTime == _publicEndTime.

If salesOption == 2 and, either by mistake or intentionally, publicEndTime is set to a past value or simply to a value of 0, the getPrice function will return a fixed price collectionPhases[_collectionId].collectionMintCost instead of the adjusted price for the descending sale.

The CollectionAdmin calls setCollectionPhases prior to minting but also for each update of the merkleRoot, increasing the probability of human error.

Tools Used

Manual Review

Recommended Mitigation Steps

  1. Implement two distinct functions to set up Public sales (setCollectionPhases) and Allowlist Sales (setAllowlistPhases) to avoid confusion, redundancy and reduce the risk of error.

  2. Add sanity checks to ensure that collectionPhasesDataStructure.allowlistEndTime is less than or equal to collectionPhasesDataStructure.publicStartTime, and that collectionPhasesDataStructure.publicStartTime is less than or equal to collectionPhasesDataStructure.publicEndTime.

Assessed type

Invalid Validation

@c4-submissions c4-submissions added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Nov 7, 2023
c4-submissions added a commit that referenced this issue Nov 7, 2023
@c4-pre-sort
Copy link

141345 marked the issue as duplicate of #1391

@c4-judge
Copy link

alex-ppg marked the issue as not a duplicate

@alex-ppg
Copy link

alex-ppg commented Dec 6, 2023

The Warden specifies that the price function will yield an incorrect value if the allowlistEndTime is specified and the publicEndTime is lower than the allowlistEndTime.

Based on the fact that the documentation does not warn against this (it only warns for the StartTime values) and that the function is callable by the collection administrator rather than the NextGen team, I consider this to be a valid QA (L) finding.

@c4-judge
Copy link

c4-judge commented Dec 6, 2023

alex-ppg changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Dec 6, 2023
@c4-judge
Copy link

c4-judge commented Dec 8, 2023

alex-ppg marked the issue as grade-c

@c4-judge c4-judge closed this as completed Dec 8, 2023
@c4-judge c4-judge added grade-c unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-c QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants