CidNFT.mint(bytes[]) allow user to mint and add subprotocol NFTs directly after minting. The _addList args to the add call include the _cidNFTID param, which can change if there are other mint before the userβs transaction.
An attacker can DOS a userβs mint and add by front-running their mint by another mint, bumping the cid nft id.
/// @notice Mint a new CID NFT
/// @dev An address can mint multiple CID NFTs, but it can only set one as associated with it in the AddressRegistry
/// @param _addList An optional list of encoded parameters for add to add subprotocol NFTs directly after minting.
/// The parameters should not include the function selector itself, the function select for add is always prepended.
function mint(bytes[] calldata _addList) external {
_mint(msg.sender, ++numMinted); // We do not use _safeMint here on purpose. If a contract calls this method, he expects to get an NFT back
bytes4 addSelector = this.add.selector;
for (uint256 i = 0; i < _addList.length; ++i) {
(
bool success, /*bytes memory result*/
) = address(this).delegatecall(abi.encodePacked(addSelector, _addList[i]));
if (!success) revert AddCallAfterMintingFailed(i);
}
}
Instead of a self delegate call, use a switch statement with abi.decode to support different type of entry, and call the internal function according with the newly generated cid nft id.
The text was updated successfully, but these errors were encountered:
All reactions