Since the ISignatureValidator contract is taken from the signature that the user passes.
He can pass his ISignatureValidator and make any signature valid, and as a result perform any transaction, because the user can set the address of ISignatureValidator in the signatures parameter
Impact
Worst cases: Collection of all funds and transfer of ownership over the contract
Now we simulate the situation which we want to test:
User A created SmartAccount, 10,000 USDT was deposited into the contract
Attacker created a fake signature and received all USDT from contract (Attacker can execute any transactions)
Tests
Tests proving the issue were added at the end project test file
with the removal of other tests present in it)
Tests:
Lines of code
https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L196 https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L218 https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L342 https://github.com/code-423n4/2023-01-biconomy/blob/53c8c3823175aeb26dee5529eeefa81240a406ba/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L312
Vulnerability details
Vulnerability details:
Short issue description:
Since the ISignatureValidator contract is taken from the signature that the user passes. He can pass his ISignatureValidator and make any signature valid, and as a result perform any transaction, because the user can set the address of ISignatureValidator in the signatures parameter
Impact
Tools Used
https://github.com/code-423n4/2023-01-biconomy/ hardhat
Recommended Mitigation Steps
Proof of Concept
Let's now analyze in detail::
The
execTransaction
andcheckSignatures
method has the following highlights::Transfer
signatures
a separate parametercall
checkSignatures
with passedsignatures
fieldsplit
signatures
get
_signer
fromr
more gate for
s
call
isValidSignature
from_signer
Let's bypass all the gates for s and substitute our _signer To pass signature validation, we can use the following signatures:
ethers.utils.hexZeroPad(fakeImpl.address, 32)
- address of attacker to standartr
bytes format0000000000000000000000000000000000000000000000000000000000000041
- selecteds
for passed all gates00
- selectedv
for go to inner firstif
for check contract signature0000000000000000000000000000000000000000000000000000000000000000
- selectedcontractSignature
for passed all gatesThen we need create Attacker contract like next:
Now we simulate the situation which we want to test: User A created
SmartAccount
, 10,000 USDT was deposited into the contract Attacker created a fake signature and received all USDT from contract (Attacker can execute any transactions)Tests
Tests proving the issue were added at the end project test file with the removal of other tests present in it) Tests:
Results