MinterContract.burnToMint
FUNCTION DOES NOT CHECK WHETHER setMintingCosts
IS SET FOR A SPECIFIC _mintCollectionID
THUS ALLOWING FREE MINTS USING THE burnToMint
FUNCTION
#1866
Labels
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
primary issue
Highest quality submission among a set of duplicates
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
sufficient quality report
This report is of sufficient quality
unsatisfactory
does not satisfy C4 submission criteria; not eligible for awards
Lines of code
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L197
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L329
Vulnerability details
Impact
In both the
MinterContract.mint
function and theMinterContract.burnOrSwapExternalToMint
functions there is a check to ensure that the minting cost of the collection is set as shown below:But the same check is not performed in the
MinterContract.burnToMint
function which is also used to mint a collection ERC721 token after burning a token of a NextGen collection. If thesetMintingCosts
is not set for the specific_mintCollectionID
it means theMinterContract.setCollectionCosts
is not called thus the parameters such ascollectionPhases[_collectionID].collectionMintCost
,collectionPhases[_collectionID].collectionEndMintCost
andcollectionPhases[_collectionID].rate
have0
as their respective values.As a result the
getPrice(_mintCollectionID)
function call inside theburnToMint
function will return0
if thesetCollectionCosts
is not set for the specific_mintCollectionID
. As a result the followingrequire
statement willpass
even formsg.value == 0
.Hence the
burnToMint
function can be called by anyone (since there is no access control) to mint ERC721 tokens without paying the underlying native tokens for the mint if thesetCollectionCosts
is not set for the specific_mintCollectionID
.Hence any address with the
approval
to burn thetokenId
or theowner
of theburning tokenId
canmint
any other NextGen collection token (with specific_mintCollectionID
) without paying the underlying mint cost given that thesetMintingCosts
is not set for that specific_mintCollectionID
.Proof of Concept
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L197
https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L329
Tools Used
Manual Review and VSCode
Recommended Mitigation Steps
Hence it is recommended to check the
setMintingCosts
condition inside theMinterContract.burnToMint
function by implementing the followingrequire
statement inside theburnToMint
function as shown below:The above modification ensures that the
setMintingCosts
is set for the specific_mintCollectionID
before minting of a new tokenId takes place. If thesetMintingCosts
is not set the transaction willrevert
not allowing any user tomint
theERC721
token for free.Assessed type
Other
The text was updated successfully, but these errors were encountered: