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

Lack of interface detection on the L2 side while depositing tokens

Summary

The L1 side of the bridge contract correctly uses ERC165 to verify token standards (e.g., ERC721) during token deposits. However, this crucial interface detection check is missing on the L2 side, which assumes tokens conform to the ERC721 standard without verification.

Vulnerability Details

The vulnerability arises due to a lack of interface detection on the L2 side, which contrasts with the L1 implementation's proper handling of token standard verification. On the L1 side, the depositTokens function uses the detectInterface method to determine if a token contract supports the ERC721 interface via ERC165:

function depositTokens(
uint256 salt,
address collectionL1,
snaddress ownerL2,
uint256[] calldata ids,
bool useAutoBurn
)
external
payable
{
// ...
CollectionType ctype = TokenUtil.detectInterface(collectionL1);
//...

The detectInterface function checks the token standard using the ERC165 interface:

function detectInterface(
address collection
)
internal
view
returns (CollectionType)
{
bool supportsERC721 = ERC165Checker.supportsInterface(
collection,
type(IERC721).interfaceId
);
if (supportsERC721) {
return CollectionType.ERC721;
}
// ...
}

However, on the L2 side, this verification step is entirely missing. The deposit_tokens function in the L2 contract does not perform any interface detection to verify if the token adheres to ERC721 standards. Instead, it directly assumes the token is ERC721:

fn deposit_tokens(
ref self: ContractState,
// ...
) {
// ...
//@audit no detectInterface as on L1
let ctype = CollectionType::ERC721;
// ...
}

This lack of verification on L2 introduces a security gap because the contract does not confirm the token's compatibility with the expected ERC721 standard using Starknet's SRC-5 (similar to Ethereum’s ERC165).

According to Starknet's SNIP-5 standard, checking interface support is crucial for adapting interactions based on the interface version and ensuring the correct handling of tokens. The absence of such checks on L2 means that non-ERC721-compliant tokens could be mistakenly treated as ERC721, potentially resulting in unexpected behaviors.

Such, interface detection is also missing in token_uri_from_contract_call in collection_manager.cairo

Impact

The absence of interface detection on L2 leads to inconsistent validation processes between L1 and L2, undermining the overall security and integrity of the bridge.

Tools Used

Manual review, Starknet Docs

Recommendations

To ensure consistency and security, implement interface detection on the L2 side using Starknet’s SRC-5 standard (the equivalent of Ethereum’s ERC165). A similar function to L1's detectInterface should be introduced, which checks if a token contract supports the ERC721 interface. This can be implemented using Openzeppelin's Cairo Library

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.