Beatland Festival

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

Unsafe Bit-Packing in encodeTokenId Allows Silent Overflow

Root + Impact

Description

When shifting collectionId left by 128 bits, the function assumes both values fit within 128 bits each. Using
uint256 parameters is misleading and dangerous.

// Helper functions to encode/decode token IDs
function encodeTokenId(uint256 collectionId, uint256 itemId) public pure returns (uint256) {
return (collectionId << COLLECTION_ID_SHIFT) + itemId;
}

Risk

  • If collectionId > type(uint128).max, the left shift will overflow and lose data

  • If itemId > type(uint128).max, it will corrupt the encoded collectionId portion

  • No validation that inputs fit within their allocated bit ranges


Recommended Mitigation

Use safe casting both collectionId and itemId to uint128.

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.