Summary
setNFTDescriptor collects an address and emits it. It doesn't check if the address is zero and just set it as newNFTDescriptor.
Vulnerability Details
Without checking for address zero, we might lose data when we try to replace the newNFTDescriptor
Impact
Little impact to the code integrity.
function test_RevertWhen_CallerNotAdmin() external {
resetPrank({ msgSender: users.eve });
vm.expectRevert(abi.encodeWithSelector(Errors.CallerNotAdmin.selector, users.admin, user.exe));
lockup.setNFTDescriptor(ISablierV2NFTDescriptor(address(0)));
}
Tools Used
manual
Recommendations
Check for address zero
function setNFTDescriptor(ISablierV2NFTDescriptor newNFTDescriptor) external onlyAdmin {
// Check that the new NFT descriptor is not the zero address
+ require(address(newNFTDescriptor) != address(0), "New NFT descriptor is the zero address");
// Effect: set the NFT descriptor.
ISablierV2NFTDescriptor oldNftDescriptor = nftDescriptor;
nftDescriptor = newNFTDescriptor;
// Log the change of the NFT descriptor.
emit SetNFTDescriptor(msg.sender, oldNftDescriptor, newNFTDescriptor);
// Refresh the NFT metadata for all streams.
emit BatchMetadataUpdate(1, nextStreamId - 1);
}