Ambire Wallet - Invitational - carlitox477's results

A web3 wallet that makes crypto self-custody easy and secure for everyone

General Information

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

Ambire

Findings Distribution

Researcher Performance

Rank: 4/5

Findings: 0

Award: $0.00

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: d3e4

Also found by: adriro, bin2chen, carlitox477, rbserver

Labels

bug
grade-b
QA (Quality Assurance)
Q-01

Awards

Data not available

External Links

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 gas

Current AmbireAccountFactory::deploySafe can be summarized in next pseudocode:

  1. Get expected deployment address
  2. If it was not deployed yet, deploy it with create2 and emit log
  3. Return the expected deployment address

However, create2 has only two possible outputs:

  • address(0) is the deployment has failed given that the contract was already deployed
  • Address different to address(0) if the contract was successfully deployed

create2 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

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter