code-423n4 / 2023-01-biconomy-findings

7 stars 9 forks source link

Replay attack on UserOperation if the smart account is not deployed before #420

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/code-423n4/2023-01-biconomy/blob/5df2e8f8c0fd3393b9ecdad9ef356955f07fbbdd/scw-contracts/contracts/smart-contract-wallet/BaseSmartAccount.sol#L64

Vulnerability details

Impact

During handling an UserOperation, if the smart account is not deployed already, it will be created and then the UserOperation will be executed. The vulnerability is that since the smart account is going to be deployed before the execution of the UserOperation, it will bypass the nonce incrementation. This provides an opportunity to apply replay attack to execute the same UserOperation twice.

Replaying a user's transaction can have critical financial impact on the user. For example, transferring fund from the user to the receiver twice instead of once.

Proof of Concept

Tools Used

Recommended Mitigation Steps

c4-judge commented 1 year ago

gzeon-c4 marked the issue as primary issue

gzeoneth commented 1 year ago

not quite sure, need further review

livingrockrises commented 1 year ago

imo validateSignature would have failed prior to getting this stage! can you showcase this with proof of test case?

livingrockrises commented 1 year ago

to replay the second op (after the wallet is already deployed) nonce is zero but you will also need to send initcode exactly the same! (when it is 0x for first op) and the userOp signature is signed over the whole struct so it will either fail with signature mismatch, or createSenderIfNeeded will revert (if you send same signature and initcode!)

c4-sponsor commented 1 year ago

livingrockrises marked the issue as sponsor disputed

c4-sponsor commented 1 year ago

livingrockrises marked the issue as disagree with severity

c4-sponsor commented 1 year ago

livingrockrises requested judge review

c4-judge commented 1 year ago

gzeon-c4 marked the issue as unsatisfactory: Insufficient proof