Uninitialized implementation can be self-destructed #39
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-496
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/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L166
Vulnerability details
Impact
Uninitialized implementation can lead to self destruction, and stop the proxies from normal working.
Proof of Concept
The
SmartAccount.sol
is not initialized during construction (no constructor is available). So, anybody can call the functioninit
for the first time and set the important variables_owner
,_entryPointAddress
, and_handler
to a malicious address.https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L166
Then, the malicious address can call the function
execFromEntryPoint
:https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L489
This function will call the function
execute
in which it delegate calls to an address deployed by the attacker which has selfdestruct function. So, theSmartAccount.sol
will be destructed, and all the proxies who point to this contract as an implementation will not working.https://github.com/code-423n4/2023-01-biconomy/blob/5df2e8f8c0fd3393b9ecdad9ef356955f07fbbdd/scw-contracts/contracts/smart-contract-wallet/base/Executor.sol#L13
Tools Used
Recommended Mitigation Steps
The following piece of code should be added to the contract
SmartAccount.sol
:The text was updated successfully, but these errors were encountered: