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

Missing URI Validation – Inadequate Input Sanitization Enables Malicious Metadata Injection

Summary

The NFTFactory contract’s createEstate function passes a user-supplied description string directly to _setTokenURI without any validation. This omission allows an attacker to set invalid, offensive, or fraudulent metadata as the token URI. Such manipulation could mislead users about the nature or legitimacy of the NFT estates, undermining trust in the system and potentially devaluing genuine assets.


Vulnerability Details

  • Affected Function:

    function createEstate(string memory description) external onlyInheritanceManager returns (uint256 itemID) {
    uint256 ID = _incrementCounter();
    _mint(msg.sender, ID);
    _setTokenURI(ID, description);
    return ID;
    }
  • Issue:
    The contract accepts any string as a token URI without validating its format or content. There are no checks to ensure the description is a well-formed URI or that it meets any predetermined quality criteria.

  • Potential Abuse:

    • An attacker or a malicious administrator (with access as the inheritanceManager) can set the token URI to an empty string, non-URI text, or even offensive content.

    • Users relying on NFT metadata for estate information could be misled, affecting their decision-making and eroding trust in the protocol.


Root Cause

The vulnerability stems from the absence of input validation or sanitization on the description parameter passed to _setTokenURI. By not verifying that the input conforms to a valid URI format (or at minimum is not empty), the contract permits any arbitrary string to be used as metadata.


Impact

  • The contract may store malicious or malformed metadata without any safeguards.


Tools Used

  • Foundry:


Proof of Concept

Mitigation

To mitigate this issue, it is recommended to implement input validation for the metadata string. Possible measures include:

  1. Non-Empty Check:
    Require that the metadata string is not empty:

    require(bytes(description).length > 0, "Description cannot be empty");
  2. Consider incorporating a library or regex check to validate that the input conforms to a proper URI format.

  3. Emit events when new estates are created so that any anomalous metadata entries can be quickly identified and reviewed.

Updates

Lead Judging Commences

0xtimefliez Lead Judge 6 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.