Submitted by ast3ros, also found by smiling_heretic, bart1e, Jiamin, Al-Qa-qa, Ruhum, ustas, rishabh, CaeraDenoir, 00xSEV, circlelooper, gumgumzum, crunch, and Juntao
The current implementation of the burnToMint function in the NextGenCore.sol smart contract permits a contract holder to both burn and sell the same NFT, effectively exploiting it to mint a new NFT. This leads to potential fraudulent activities when trading the NFT.
The vulnerability stems from the order of operations in the burnToMint function. Currently, a new token is minted (_mintProcessing) before the existing token is burned (_burn). This sequence of operations opens a window for exploitation:
https://github.com/code-423n4/2023-10-nextgen/blob/58090c9fbc036c06bbaa9600ec326034f2181a17/hardhat/smart-contracts/NextGenCore.sol#L213-L223
The _mintProcessing function calls _safeMint, which in turn can trigger arbitrary code execution if the recipient is a contract. This allows for manipulation such as transferring the NFT (set to be burned) to another user before the burn occurs:
https://github.com/code-423n4/2023-10-nextgen/blob/58090c9fbc036c06bbaa9600ec326034f2181a17/hardhat/smart-contracts/NextGenCore.sol#L227-L232
A malicious actor can exploit this by listing the NFT for sale. When there is a buy offer, the malicious contract can call burnToMint to receive the new NFT and simultaneously accept an offer to buy the original NFT, resulting in the original NFT being burned but still sold, effectively duping the buyer.
In this POC scenario, there are two collections; 1 and 2. The admin is set so that users can burn token in collection 1 to mint token in collection 2.
POC:
The order of operations in the burnToMint function should be revised to ensure that the token is burned before a new one is minted:
Reentrancy
a2rocket (NextGen) confirmed and commented:
0xsomeone (judge) decreased severity to Medium and commented:
0xsomeone (judge) commented:
