Submitted by 0xdeadbeef0x, also found by V_B, gogo, gogo, Fon, adriro, Tricko, immeas, Haipls, ayeslick, wait, Lirios, Koolex, Atarpara, bin2chen, hihen, ast3ros, wallstreetvilkas, romand, ladboy233, ro, BClabs, StErMi, static, Manboy, csanuragjain, and kankodu
A hacker can create arbitrary transaction through the smart wallet by evading signature validation.
Major impacts:
The protocol supports contract signed transactions (eip-1271). The support is implemented in the checkSignature call when providing a transaction:
contracts/smart-contract-wallet/SmartAccount.sol#L218
contracts/smart-contract-wallet/SmartAccount.sol#L342
checkSignature DOES NOT Validate that the _signer or caller is the owner of the contract.
A hacker can craft a signature that bypasses the signature structure requirements and sets a hacker controlled _signer that always return EIP1271_MAGIC_VALUE from the isValidSignature function.
As isValidSignature returns EIP1271_MAGIC_VALUE and passed the requirements, the function checkSignatures returns gracefully and the transaction execution will continue. Arbitrary transactions can be set by the hacker.
Impact #1 - Self destruct and steal all funds
Consider the following scenario:
Impact #2 - Update implementation and lock out EOA
Foundry POC
The POC will demonstrate impact #1. It will show that the proxy does not exist after the attack and EOAs cannot interact with the wallet.
The POC was built using the Foundry framework which allowed me to validate the vulnerability against the state of deployed contract on goerli (Without interacting with them directly). This was approved by the sponsor.
The POC use a smart wallet proxy contract that is deployed on goerli chain:
proxy: 0x11dc228AB5BA253Acb58245E10ff129a6f281b09
You will need to install a foundry. Please follow these instruction for the setup: https://book.getfoundry.sh/getting-started/installation
After installing, create a workdir by issuing the command: forge init --no-commit
Create the following file in test/DestroyWalletAndStealFunds.t.sol:
To run the POC and validate that the proxy does not exist after destruction:
Expected output:
To run the POC and validate that the EOA cannot interact with the wallet after destruction:
Expected output:
Foundry, VS Code
The protocol should validate before calling isValidSignature that _signer is owner.
livingrockrises (Biconomy) confirmed
