HardhatFoundry
30,000 USDC
View results
Submission Details
Severity: low
Invalid

Create2 address collision during account deployment

Summary

The createAccount method in Factory calls the createDeterministically method from LibClone that uses the create2 opcode. The create2 method also has a salt parameter that is passed to the createDeterministicallyERC1967 call. A malicious actor can front-run every call to create2 and use the same salt argument. This will result in reverts of all user transactions, as there is already a Nexus account at the address that create2 tries to deploy to.

Vulnerability Details

https://github.com/Cyfrin/2024-07-biconomy/blob/9590f25cd63f7ad2c54feb618036984774f3879d/contracts/factory/K1ValidatorFactory.sol#L93

https://github.com/Cyfrin/2024-07-biconomy/blob/9590f25cd63f7ad2c54feb618036984774f3879d/contracts/factory/NexusAccountFactory.sol#L56

https://github.com/Cyfrin/2024-07-biconomy/blob/9590f25cd63f7ad2c54feb618036984774f3879d/contracts/factory/RegistryFactory.sol#L123

The address collision an attacker will need to find are:

  • One undeployed Nexus address (1).

  • Arbitrary attacker-controlled wallet contract (2).

Both sets of addresses can be brute-force searched because:

  • As shown above, salt is a user-supplied parameter. By brute-forcing many salt values, we have obtained many different (undeployed) wallet accounts for (1). The user can know the address of the Nexus accounts before deploying it, since as seen in the code comments, the result is deterministic.

  • (2) can be searched the same way. The contract just has to be deployed using CREATE2, and the salt is in the attacker's control by definition.

An attacker can find any single address collision between (1) and (2) with high probability of success using the following meet-in-the-middle technique, a classic brute-force-based attack in cryptography:

  • Brute-force a sufficient number of values of salt (2^80), pre-compute the resulting account addresses, and efficiently store them e.g. in a Bloom filter data structure.

  • Brute-force contract pre-computation to find a collision with any address within the stored set in step 1.

References

The hashrate of the BTC network has reached 6.5 x 10^20 hashes per second as of time of writing, taking only just 31 minutes to achieve 2^80 hashes. A fraction of this computing power will still easily find a collision in a reasonably short timeline.

Impact

Address collision leading to DOS for users

Tools Used

Various articles

Recommendations

Adding msg.sender to the salt argument passed to cloneDeterministically will resolve this issue.

Updates

Lead Judging Commences

0xnevi Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

finding-createAccount-frontrun-salt

Invalid if a new Nexus proxy is already deployed, [`createDeterministicERC1967` will not revert](https://github.com/Vectorized/solady/blob/main/src/utils/LibClone.sol#L745), but simply return, so there is no DoS here. Users should carefully select a unique salt and initData when creating a new Nexus Proxy instance as noted in documentation [here](https://github.com/bcnmy/nexus/wiki/NexusAccountFactory#createaccount)

Support

FAQs

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