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

Unbounded Loop Vulnerability in Token Deposit Function

Summary

The depositTokens function in the Starklane bridge contract accepts an unsanitized array of token IDs, potentially leading to unbounded loops and out-of-gas issues during execution in _depositIntoEscrow.

Vulnerability Details

In the depositTokens function, the ids parameter is declared as follows:

function depositTokens(
uint256 salt,
address collectionL1,
snaddress ownerL2,
uint256[] calldata ids, 2 // <-@
bool useAutoBurn
)
external
payable
{
// ... (other code)
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
// ... (processing each token ID)
}
// ... (rest of the function)
}

The function does not impose any limit on the length of the ids array. This lack of input validation can lead to the following issues:

  • An attacker could provide an extremely large array of token IDs, causing the loop to consume excessive gas.

  • If the array is too large, it may exceed the block gas limit, making the transaction impossible to execute.

  • Even if the transaction doesn't fail outright, it may become prohibitively expensive to execute, effectively DoS-ing the function.

Impact

Denial of Service (DoS) attacks on the bridge contract and Excessive gas costs for users attempting legitimate large transfers and also Potential blocking of the entire bridging process if a transaction with too many IDs cannot be processed.
The severity is high due to the potential for DoS attacks and the fundamental disruption to the bridge's core functionality.

Tools Used

Manual code review

Recommendations

Implement a maximum limit for the ids array length:
uint256 constant MAX_IDS_PER_DEPOSIT = 100; // Adjust this value as appropriate

function depositTokens(
uint256 salt,
address collectionL1,
snaddress ownerL2,
uint256[] calldata ids,
bool useAutoBurn
)
external
payable
{
require(ids.length > 0 && ids.length <= MAX_IDS_PER_DEPOSIT, "Invalid number of token IDs");
// ... (rest of the function)
}
Updates

Lead Judging Commences

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