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

No checks on token_id uniqueness

Summary

No checks on token_id uniqueness.

Vulnerability Details

The function processes a list of token IDs without verifying whether each token_id is unique within the request. Here's the relevant part of the code:

let mut i = 0;
loop {
if i == req.ids.len() {
break ();
}
let token_id = *req.ids[i];
// ... processing logic ...
i += 1;
}

https://github.com/Cyfrin/2024-07-ark-project/blob/273b7b94986d3914d5ee737c99a59ec8728b1517/apps/blockchain/starknet/src/bridge.cairo#L146C8-L174C11

The problem here is that the same token_id could appear multiple times in req.ids, and the function would process it each time without any checks.

Suppose the request contains token IDs [1, 2, 1], and all these tokens are initially escrowed by the bridge contract.

  • The first occurrence of token 1 is processed: It's successfully transferred to the recipient.

  • Token 2 is processed: It's successfully transferred.

  • The second occurrence of token 1 is processed: The transfer attempt will fail because the bridge no longer owns this token.

Impact

The function will attempt to transfer the same token again. This will fail because the bridge contract no longer owns the token after the first transfer.

Tools Used

Manual review

Recommendations

Implement checks for token ID uniqueness within each request.

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.