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

Potential Reentrancy Vulnerability Due to Non-Compliance with Checks-Effects-Interactions Pattern

Summary

The function _withdrawFromEscrow does not fully adhere to the Checks-Effects-Interactions (CEI) pattern, which could potentially expose the contract to reentrancy attacks. The function performs an external call to safeTransferFrom which triggers a callback to an arbitrary address before the internal state is updated, though there are some mitigating factors in place.

Vulnerability Details

The _withdrawFromEscrow function interacts with external contracts through safeTransferFrom and potentially exposes the contract to reentrancy attacks due to the order of operations. Here’s a breakdown:

  • Checks: The function checks whether the token is escrowed using _isEscrowed.

  • Effects: The internal state _escrow is updated after the external call.

  • Interactions: The function interacts with external contracts via safeTransferFrom.

Reentrancy Risks:

  • ERC721 Collection: safeTransferFrom for ERC721 tokens calls out to external function onERC721Received in the receivers contract (if the receiver is a contract), which could trigger reentrancy attacks if the external contract is malicious.

  • ERC1155 Collection: While ERC1155’s safeTransferFrom also interacts with external contracts, it is currently not implemented, but it may pose similar risks when implemented.

Impact

Reentrancy vulnerabilities can lead to:

  • Loss of Tokens: Malicious contracts could exploit the vulnerability to withdraw tokens multiple times.

  • Inconsistent State: The contract’s internal state might become inconsistent if an external call is exploited.

Tools Used

Manual Code Review: Identified CEI pattern violations and potential reentrancy risks.

Recommendations

Move State Updates Before External Calls: Update the internal state _escrow before calling safeTransferFrom. This will prevent reentrancy attacks as the contract’s state is updated before the external call is made.

_escrow[collection][id] = address(0x0);
if (collectionType == CollectionType.ERC721) {
ERC721Bridgeable(collection).safeTransferFrom(from, to, id);
} else {
// Handle ERC1155 case
}
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality
Assigned finding tags:

finding-withdraw-reentrancy-creates-unbridgeable-tokens

Impact: - NFT already bridged won’t be bridgeable anymore without being stuck. Likelyhood: Low. - Attackers will corrupt their own tokens, deploying a risky contract interacting with an upgradable proxy. They have to buy and sell them without real benefits, except being mean. Some really specific and rare scenario can also trigger that bug.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.