40,000 USDC
View results
Submission Details
Severity: gas

Vulnerables in the EscrowFactory.sol file

Summary

The code appears to be a Factory contract for deploying Escrow contracts. It provides a function to create a new Escrow contract with specified parameters. The Factory contract uses a computeEscrowAddress function to predict the address of the new Escrow contract before deployment.

Vulnerability Details

The computeEscrowAddress function uses the keccak256 hash of contract bytecode and parameters to predict the address of the new Escrow contract. This predictable address could be exploited by malicious actors to front-run the deployment and deploy a contract with the same parameters before the intended user, potentially leading to unintended escrow creation.

Reentrancy Vulnerability: The newEscrow function allows the Factory contract to transfer tokens from the msg.sender to the computed Escrow address before deploying the contract. If the Escrow contract or the token contract's transferFrom function contains reentrancy vulnerabilities, it could lead to unexpected behaviors and attacks.

Impact

The identified vulnerabilities could have serious consequences on the security and reliability of the EscrowFactory contract. Front-running attacks can disrupt the escrow creation process and result in unwanted escrows. Additionally, if the Escrow contract or token contract has reentrancy vulnerabilities, it could lead to potential token loss and contract malfunctions.

Tools Used

Manual and documentation

Recommendations

Randomized Salt Generation: Consider using a more random salt generation method, such as using a combination of block timestamp, block number, and other variables, to prevent predictable address generation and front-running attacks.

Reentrancy Protection: Implement reentrancy protection in the newEscrow function to prevent potential reentrancy attacks. One approach is to use the OpenZeppelin ReentrancyGuard or similar mechanisms.

Gas Optimization: Be mindful of the gas cost while predicting the address of the new Escrow contract. If the gas cost is significantly high, it might affect the contract deployment and execution.

Security Audit: Conduct a thorough security audit of the EscrowFactory contract, including its interactions with other contracts, to identify and mitigate any potential security risks.

Support

FAQs

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