Deterministic wallet deployments can be frontrun or preemptively deployed and then have ownership stolen #135
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-460
edited-by-warden
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/SmartAccountFactory.sol#L33-L45
Vulnerability details
Impact
When deploying a smart-account using
SmartWalletFactory.deployCounterFactualWallet
, the arguments_entryPoint
and_handler
are not used when calculating thecreate2
deployment address. An attacker could see a user deterministically deploying a smart-account and frontrun their transaction, changing the_entryPoint
argument to their own address. Once the smart-account is deployed, the attacker can callSmartAccount.execFromEntryPoint
since they are in control of the entrypoint address. They can use this function to execute a call to its own address, specifically thesetOwner
function as it has themixedAuth
modifier. The attacker now has full ownership of the smart-wallet.This applies to more than just frontrunning however. A feature of deterministic account abstraction is the ability to deploy smart-accounts across multiple chains with the same address. An attacker could follow the steps above to prevent a user from being able to use the same smart-account across multiple chains by preemptively deploying.
It is also a known practice to send funds to an address that you know you will be able to deterministically deploy to, without having deployed the contract until you need to make a transaction. If a user with a deterministically deployed smart-account on Ethereum is expecting payment on Polygon, they can provide the same address for Polygon knowing they can deploy and move the funds at a later time. An attacker would be able to steal these funds.
On top of stealing ownership and funds, it is possible to use this as a DOS against wallet deployments, as each deployment by the user will fail since the frontrun deployment executes first.
Proof of Concept
The following test can be added to the end of
test/aa-core/entrypoint.test.ts
Tools Used
Recommended Mitigation Steps
The
owner
address could sign the arguments used when attempting to deploy and pass this as an additional argument. This signature can then be verified against theowner
address to ensure that arguments have not been tampered with.The text was updated successfully, but these errors were encountered: