If the Escrow contract creation fails for any reason, then the tokens will already have been transferred to an address which might not be accessible, resulting in the loss of these tokens.
If the creation of the escrow in the newEscrow()
function of the EscrowFactory.sol
contract fails for any reason, the transferred funds will be lost.
This happens because not creating a contract throws an exception. Interrupt the execution of the operation and therefore not reach the proposed reversal to reverse the operation.
Therefore, if the token transfer is successful and then escrow creation fails, the token transfer is not rolled back.
A useful resource that helped me confirm this vulnerability was the link I shared, in the last paragraph it says:
High, the buyer can lose all your funds.
Manual code review
To solve this problem, you can reorder the operations in such a way that the token transfer is done only after the Escrow contract has been successfully created and to make it more secure after the address has been verified.
And delete from the constructor of Escrow because this statement will now be evaluated from the EscrowFactory:
In this case, if the creation of the Escrow contract fails or if the calculated address does not match the actual address of the contract, the transfer of tokens will not take place and there will be no risk of losing tokens.
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.