Beatland Festival

First Flight #44
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

Token ID Collision Vulnerability in encodeTokenId

Root + Impact

If either collectionId or itemId is allowed to be 128 bits or greater, collisions can occur. For example:
(collectionId: 1, itemId: 0) → tokenId = 2^128
(collectionId: 0, itemId: 2^128) → tokenId = 2^128
Both pairs produce the same tokenId, meaning two different NFTs would be indistinguishable in the system.

Description

The contract uses the following logic to combine a collectionId and an itemId into a single ERC1155 token ID:

// tokenId = (collectionId << 128) + itemId;

This is intended to uniquely encode a pair of 128-bit values into a single 256-bit value


Risk

Likelihood:

This bug can lead to loss of uniqueness, data corruption, and potential exploits.

Impact

  • Token ID Collision:

Different (collectionId, itemId) pairs can map to the same tokenId.

  • Loss of Uniqueness:

This breaks the uniqueness guarantee of token IDs, which can lead to:

  • Incorrect ownership tracking

  • Metadata confusion

  • Potential exploits (e.g., minting or transferring unintended NFTs)


Recommended Mitigation

Enforce 128-bit Limits:


Add require statements to ensure both collectionId and itemId are strictly less than 2^128:

+ require(collectionId < 2**128, "collectionId overflow");
+ require(itemId < 2**128, "itemId overflow");
Updates

Lead Judging Commences

inallhonesty Lead Judge about 2 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.