The current design allows for potential exploitation when the token with a hook. This vulnerability emerges during the arbitration process because the contract attempts to send any unallocated funds to the seller. This setup inadvertently offers an opportunity for the seller to front-run, thereby ensuring the token's transfer hook is triggered. If the seller then revert in the hook, it blocks the transaction from being executed. This exploit not only undermines the functionality of the arbitration process, but also poses the risk of freezing the funds within the contract.
https://github.com/Cyfrin/2023-07-escrow/blob/65a60eb0773803fa0be4ba72defaec7d8567bccc/src/Escrow.sol#L109-L129
Alice, a buyer who uses an ERC777 token.
Bob, a seller who has control over the token's hooks.
Alice deposits 1000 ERC777 tokens into the contract.
A dispute arises and the arbitrator rules in favor of Alice. The arbitrator's decision triggers the contract to transfer all 1000 tokens back to Alice.
Before the transfer transaction is mined, Bob performs a front-running attack. He transfers 1 wei of ERC777 tokens to the contract.
Due to the transfer, Bob's tokensToSend
hook is triggered. He then causes the tokensToSend
hook to fail, which blocks the transfer of the 1000 tokens to Alice.
The arbitrator's transaction is then mined, but the transfer fails due to Bob's earlier front-running transaction and hook manipulation.
Alice expected to receive her 1000 ERC777 tokens after the dispute resolution but the transfer fails. Bob can keep doing this and make the funds remain frozen in the contract.
The current design could lead to locked funds within the contract if an ERC777 token (hook token) is used. This can occur when a dispute is raised and the arbitrator rules in favor of the buyer, but the seller uses the token hook to prevent the transaction from occurring, thus freezing the funds within the contract.
Auditor's brain & ChatGPT & VS Code
Consider modifying the contract to:
Add a function that allows the seller to withdraw funds when a transfer fails.
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.