Beginner FriendlySolidity
100 EXP
View results
Submission Details
Severity: high
Invalid

Vulnerability in burnEstate Function Due to Absence of Array

Summary

This review addresses the absence of an array to store the IDs of active estates in the NFTFactory smart contract. Storing active estate IDs in an array allows for efficient management and checking of estate existence.

Vulnerability Details

  • Description : The contract does not maintain an array to store active estate IDs. This makes it difficult to efficiently check if an estate exists before burning it.

  • Impact : Without an array, the contract cannot efficiently verify the existence of an estate ID, leading to potential errors and inefficiencies.

Impact

  • Incorrect Estate Burning : Attempting to burn a non-existent estate ID can lead to errors and unexpected behavior, causing the transaction to fail.

  • IDs Stuck : Without proper management of active estate IDs, certain IDs may become stuck and cannot be burned, leading to inconsistencies in the contract state.

  • Inefficient Management : Without an array, managing active estate IDs becomes inefficient.

Tools Used

  • Manual Code Review

Recommendations

  • Add an Array to Store Active Estate IDs after calling the createEstate function

uint256 [] activeEstates;
function createEstate(string memory description) external onlyInheritanceManager returns (uint256 itemID) {
uint256 ID = _incrementCounter();
_mint(msg.sender, ID);
_setTokenURI(ID, description);
activeEstates.push(ID); // Add the new estate ID to the active estates array
emit EstateCreated(ID, msg.sender, description); // Emit event
return ID;
}
  • Check if id exists in the activeEstates array in the burnEstatefunction

  • Use a linear search to find the ID and remove it by moving the last element to the current position and popping the array. For instance:

    ...
    if (activeEstates[i] == _id) {
    // Move the last element to the current position and remove the last element
    activeEstates[i] = activeEstates[length - 1];
    activeEstates.pop();
    break;
    }
    }
Updates

Lead Judging Commences

0xtimefliez Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.