Tranaction Replay Attack in SmartAccount.sol #210
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-36
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/main/scw-contracts/contracts/smart-contract-wallet/SmartAccount.sol#L212
https://github.com/code-423n4/2023-01-biconomy/blob/main/scw-contracts/contracts/smart-contract-wallet/SmartAccountNoAuth.sol#L205
Vulnerability details
Tranaction Replay Attack
Impact
execTransaction
inSmartAccount.sol
suffers from Transaction Replay Attack:A
transaction T
to be executed on onebatch X
, will be accepted by anotherbatch Y
whenbatch Y
reaches to same nonce value astransaction T
's.As a consequence:
0
) can be directly double spent, by re-submitting it to a new batch.Transaction T
(onbatch X
) and anybatch Y
, and double spentT
onY
.Detail
execTransaction
takes a paramterbatchId
.nonce A
used intransaction T
(onebatch X
) may be also used in anotherbatch Y
.transaction T
will be accepted onbatch Y
, when the nonce value ofbatch Y
reachesA
.Proof of Concept
The PoC is based on
./test/smart-wallet/testGroup1.ts
:To run the Poc:
You should see logs like
which means a transaction on
batch 0
is replayed onbatch 1
, and charlie gets twice ethers than expected.Recommended Mitigation Steps
A unique factor should be encoded to prevent collision between batches.
A quick fix could add
bachtId
as one of the parameters ofencodeTransactionData
.The text was updated successfully, but these errors were encountered: