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

Lack of Validation in `mint_range` Function Can Lead to Unintended Behavior (`erc721_bridgeable::mint_range`)

Summary

Vulnerability Details

The mint_range function in the erc721_bridgeable contract is designed to mint a range of tokens from a start value to an end value. This function is part of the ERC721BridgeableMintableImpl implementation, which allows the contract owner to mint multiple tokens in a single transaction. The function iterates from the start value to the end value, calling the mint function for each token ID in the range.

However, the mint_range function does not validate the start and end values before entering the loop. If the start value is greater than or equal to the end value, the function could exhibit unintended behavior. This lack of validation can lead to issues such as minting no tokens or minting tokens in an unexpected manner.

The relevant code snippet is as follows:

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;
}
}

Impact

The lack of validation in the mint_range function can lead to unintended behavior if the start value is greater than or equal to the end value. This can result in minting no tokens or minting tokens in an unexpected manner, which can disrupt the intended token distribution.

Proof of Concept

  1. The contract owner calls the mint_range function with start value greater than or equal to the end value.

  2. The function does not mint any tokens because the loop condition if token_id == end { break (); } is immediately met.

Example:

  • start = 10

  • end = 5

  • The loop will terminate immediately, and no tokens will be minted.

Tools Used

Manual review

Recommendation

Add validation to ensure that the start value is less than the end value before entering the loop.

fn mint_range(ref self: ContractState, to: ContractAddress, start: u256, end: u256) {
assert(start < end, 'Invalid range: start must be less than end');
let mut token_id = start;
loop {
if token_id == end {
break ();
}
self.mint(to, token_id);
token_id += 1_u256;
}
}
Updates

Lead Judging Commences

n0kto Lead Judge 12 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.