NFTBridge
60,000 USDC
View results
Submission Details
Severity: low
Invalid

`erc721_bridgeable::mint_range` function does not mint any NFTs when `start == end`

Summary

The mint_range function in the ERC721BridgeableMintableImpl contract does not mint any NFTs when start == end. This behavior is likely contrary to user expectations, as users might expect at least one NFT to be minted when start and end are the same.

Vulnerability Details

The mint_range function is designed to mint a range of NFTs from start to end. However, the current implementation contains a loop that only executes when start != end. As a result, if a user calls mint_range with start equal to end, the loop does not execute, and no NFTs are minted:

fn mint_range(ref self: ContractState, to: ContractAddress, start: u256, end: u256) {
let mut token_id = start;
loop {
if token_id == end {
break ();
}
self.mint(to, token_id);
token_id += 1_u256;
}
}

In this case, the loop condition (token_id == end) is met immediately, causing the loop to exit before any minting occurs. The general convention in a range function is either to include start and exclude end, or include end and exclude start or include start and end - the current implementation excludes both start and end when both are equal.

This behavior is likely to be unexpected for users, who might reasonably assume that calling mint_range with start equal to end would result in the minting of a single NFT with the specified token_id.

Impact

The function's behavior does not align with common user expectations for range-based minting functions.

Tools Used

Manual Review.

Recommendations

Consider modifying the mint_range function to handle the case where start == end by minting a single NFT with the start (or end) value as the token_id.

Updates

Lead Judging Commences

n0kto Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational / Gas

Please, do not suppose impacts, think about the real impact of the bug and check the CodeHawks documentation to confirm: https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity A PoC always helps to understand the real impact possible.

Support

FAQs

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