The escrow contract contains a reentrancy vulnerability that allows an attacker to withdraw tokens during the deposit process, potentially leading to unauthorized access and theft of assets.
The _withdrawFromEscrow
function lacks proper reentrancy protection. This flaw allows an attacker to call the withdrawFromEscrow
function during the execution of the depositIntoEscrow
function, leading to unexpected behavior and unauthorized withdrawal of tokens.
An attacker can exploit this vulnerability to drain assets from the escrow contract by re-entering the contract during the deposit phase. This could result in significant financial loss for the users of the contract.
Manual Review
Place this test in your Escrow.t.sol file :
Minting Tokens: Alice mints 10 ERC721 tokens (IDs 0-9) to her account.
Prepare Tokens for Deposit: Alice prepares two token IDs (5 and 8) for deposit into the escrow contract.
Start Prank: The testing framework's prank feature is activated to simulate Alice's actions.
Deposit Tokens: Alice deposits the selected tokens (IDs 5 and 8) into the escrow contract.
Reentrancy Exploit: During the deposit, the withdrawFromEscrow
function is called to withdraw token ID 5 to Bob's account.
Result: Token ID 5 is transferred to Bob, showing that an unauthorized withdrawal occurred during the deposit.
To mitigate this vulnerability, implement a reentrancy guard on the withdrawFromEscrow
function. This can be done by using the nonReentrant
modifier provided by libraries like OpenZeppelin or by implementing a custom reentrancy guard to ensure that no reentrant calls can be made during sensitive operations.
Use a CEI(Checks Effects Interactions) Pattern for writing code.
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.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.