reentracy attack on [burnToMint](https://github.com/code-423n4/2023-10-nextgen/blob/main/smart-contracts/MinterContract.sol#L258) function #897
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-411
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#L258
Vulnerability details
Vulnerability details
burnToMintCollections[_burnCollectionID][_mintCollectionID]
set totrue
. by calling the function burnToMint fromNextGenMinterContract
contract.NextGenCore
contract:_mintCollectionID
before burning the token by calling_mintProcessing()
function ._mintProcessing()
function uses_safeMint()
to mint the token. which make an external call to the_recipient
if it's a contract's._recipient
will be able to reenter the contract by using a contract that calls burnToMinteach time it's
onERC721Received()
function get called from theNextGenCore
contract with the same token to be burned before it get burned . and mint another token from the same collection with each call.impact
mintToBurn
each time the contract callsonERC721Received()
.collectionTotalAmount[_mintCollectionID] = collectionTotalAmount[_mintCollectionID] + msg.value;
will be wrong . since the attacker is providing the price of token to be minted(msg.value) each time he mint a new token. whilecollectionTotalAmount[_mintCollectionID] = collectionTotalAmount[_mintCollectionID] + msg.value;
get recoded only for once ofter the reentrency ends.tool used
vs code
manual review
Recommended Mitigation Steps
Assessed type
Reentrancy
The text was updated successfully, but these errors were encountered: