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

Lack of Duplicate Check in tokenIds Array in `Bridge.sol::withdrawTokens` Function

Description:

The Bridge.sol::withdrawTokens function currently lacks a mechanism to detect and prevent duplicate entries in the tokenIds array. This absence of validation allows for the possibility of the same token ID being processed multiple times within a single transaction. The function iterates over the tokenIds array to either withdraw tokens from escrow or mint new tokens, assuming each token ID is unique. If duplicates are present, the function might inadvertently perform multiple operations on the same token, leading to potential issues.

Impact:

  • Incorrect Token Balances: Processing duplicate tokenIds could result in multiple transfers or mintings of the same token, leading to an incorrect token balance or state within the contract.

  • Minting Errors: Duplicate entries might cause the contract to attempt minting the same token multiple times, which could lead to minting errors or contract failures, especially if the contract logic does not account for such scenarios.

  • Operational Inconsistencies: The presence of duplicate token IDs could create inconsistencies in the contract’s state, undermining the reliability and predictability of the token withdrawal process.

  • User Confusion and Loss of Trust: Users might experience unexpected behavior, such as receiving incorrect token balances or failed transactions, which could lead to confusion, loss of trust, and negative perceptions of the system's reliability.

Recommended Mitigation:

To prevent these potential issues, implement a check within the Bridge.sol::withdrawTokens function to ensure that the tokenIds array contains only unique values before processing. This could be done by:

  • Manual Check: Implement a manual loop to compare each token ID with the others in the array, reverting the transaction if duplicates are found.

  • Using a Set Data Structure: Utilize a set or similar data structure that inherently disallows duplicate entries, ensuring that the tokenIds array is free of duplicates.

function withdrawTokens(
uint256[] calldata request
)
external
payable
returns (address)
{
// Check for duplicates
for (uint256 i = 0; i < req.tokenIds.length; i++) {
for (uint256 j = i + 1; j < req.tokenIds.length; j++) {
require(req.tokenIds[i] != req.tokenIds[j], "Duplicate token ID detected");
}
}
// Existing function logic
}
Updates

Lead Judging Commences

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