Attackers can control any smart contract wallet by deploying it #331
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-460
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/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L166-L176
https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccountFactory.sol#L33
https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccountFactory.sol#L53
Vulnerability details
Impact
Any SCW(smart contract wallet) can be hacked by deploying it (or front-running deployment), the hacker will be able to become the owner and have complete control over it.
All funds in all undeployed SCWs can be stolen.
Proof of Concept
When deploying an SCW through deployCounterFactualWallet or deployWallet, the deployer (msg.sender) can provide any address as its entrypoint.
If an attacker deploys someone else's SCW using a malicious contract as the entrypoint, he will be able to control the SCW completely through that malicious entrypoint (e.g. take the ownership of the SCW).
For example, an attacker (address X) wants to steal an SCW (address scw) which should have been belonged to a victim (address V) after deployment:
deployCounterFactualWallet(address _owner, address _entryPoint, address _handler, uint _index)
with parameters:owner = V
,_entryPoint = X
.execFromEntryPoint(address dest, uint value, bytes calldata func, Enum.Operation operation, uint256 gasLimit)
to the deployed SCW (proxy) with parameters:dest = scw
,func = setOwner(X)
.Test code for PoC (use a customized attack contract - Hack.sol to perform the attack):
Tools Used
VS Code
Recommended Mitigation Steps
Use a public EntryPoint contract as the default entrypoint in deployCounterFactualWallet and deployWallet.
A custom entrypoint should be allowed only if
msg.sender == owner
.Implementation:
The text was updated successfully, but these errors were encountered: