Platform: Code4rena
Start Date: 23/05/2023
Pot Size: $32,600 USDC
Total HM: 5
Participants: 5
Period: 3 days
Judge: Picodes
Total Solo HM: 4
Id: 243
League: ETH
Rank: 4/5
Findings: 0
Award: $0.00
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: d3e4
Also found by: adriro, bin2chen, carlitox477, rbserver
Data not available
AmbireAccountFactory::deploy
only allows deploying contract which does not require ETH during its deployment.Current implementation of deploy
only allows to deploy smart contract which does not require ETH during their deployment, contradicting the comment @notice allows anyone to deploy any contracft with a specific code/salt
This happens because, when a contract is created, a payment of 0 ether is enforced
// In deploySafe, which is called by deploy assembly { addr := create2( 0, // payment in eth add(code, 0x20), mload(code), salt) }
The comment or the code should be modified in order to be congruent
AmbireAccountFactory::deploySafe
can be refactor in order to save gasCurrent AmbireAccountFactory::deploySafe
can be summarized in next pseudocode:
create2
and emit logHowever, create2
has only two possible outputs:
address(0)
is the deployment has failed given that the contract was already deployedaddress(0)
if the contract was successfully deployedcreate2
can also revert for many reasons, for instance if the transaction run out of gas.
Therefore there is no need to check the size of the address where the code is going to be deployed.
Therefore the function can be redefine as
function deploySafe(bytes memory code, uint256 salt) internal returns (address) { address addr; assembly { addr := create2(0, add(code, 0x20), mload(code), salt) } if (addr == address(0)){ // Already deployed address case return address( uint160(uint256(keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, keccak256(code))))) ); } // If the contract was not deployed yet emit event and return new address emit LogDeployed(addr, salt); return addr; }
#0 - c4-judge
2023-05-28T16:05:52Z
Picodes marked the issue as grade-b