Cyfrin / 2023-07-escrow

16 stars 12 forks source link

Contracts can be created before execution and the Attacker can make a signer gate creation fail #837

Closed codehawks-bot closed 1 year ago

codehawks-bot commented 1 year ago

Contracts can be created before execution and the Attacker can make a signer gate creation fail

Severity

High Risk

Relevant GitHub Links

https://github.com/Cyfrin/2023-07-escrow/blob/main/src/EscrowFactory.sol#L20-L53

Summary

The EscrowFactory#newEscrow() function creates a new escrow contract with the provided parameters: price, token contract, seller, arbiter, arbiter fee, salt.

On the other hand the helper computeEscrowAddress() function computes the deterministic address where the escrow contract will be deployed, based on the provided parameters and the rules for salted contract creations (CREATE2).

Vulnerability Details

The vulnerability occurs since the computeEscrowAddress() computation is deterministic and depends on the provided parameters: price, token contract, seller, arbiter, arbiter fee, salt.

Impact

There are several potential issues:

Tools Used

Manual Review

Recommendations

Consider checking for the contracts in advance at the predicted addresses in EscrowFactory#newEscrow() and not deploying if they are already there. In this case, consider also checking that the contract’s code is as expected