Cross-Chain Signature Replay Attack
The paymaster's signature hash for user operations omitted the chain ID, so the same signed operation could be replayed on a different chain. An attacker could reuse a user's signed operation to have the paymaster sponsor transactions on another chain, potentially causing financial loss to the paymaster.
Submitted by gogo, also found by V_B and taek
User operations can be replayed on smart accounts accross different chains. This can lead to user’s losing funds or any unexpected behaviour that transaction replay attacks usually lead to.
Proof of Concept
As specified by the EIP4337 standard to prevent replay attacks ... the signature should depend on chainid. In VerifyingSingletonPaymaster.sol#getHash the chainId is missing which means that the same UserOperation can be replayed on a different chain for the same smart contract account if the verifyingSigner is the same (and most likely this will be the case).
Recommended Mitigation Steps
Add the chainId in the calculation of the UserOperation hash in VerifyingSingletonPaymaster.sol#getHash
function getHash(UserOperation calldata userOp)
public view returns (bytes32) { // @audit change to view
//can't use userOp.hash(), since it contains also the paymasterAndData itself.
return keccak256(abi.encode(
userOp.getSender(),
userOp.nonce,
keccak256(userOp.initCode),
keccak256(userOp.callData),
userOp.callGasLimit,
userOp.verificationGasLimit,
userOp.preVerificationGas,
userOp.maxFeePerGas,
userOp.maxPriorityFeePerGas
block.chainid // @audit add chain id
));
}
livingrockrises (Biconomy) confirmed
gzeon (judge) decreased severity to Medium
vlad_bochok (warden) commented:
@gzeon @livingrockrises
User operations can be replayed on smart accounts accross different chains
The author refers that the operation may be replayed on a different chain. That is not true. The “getHash” function derives the hash of UserOp specifically for the paymaster’s internal usage. While the paymaster doesn’t sign the chainId, the UserOp may not be relayed on a different chain. So, the only paymaster may get hurt. In all other respects, the bug is valid.
The real use case of this cross-chan replayability is described in issue
#504(which, I believe, was mistakenly downgraded).
livingrockrises (Biconomy) commented:
True. Besides chainId , address(this) should be hashed and contract must maintain it’s own nonces per wallet otherwise wallet can replay the signature and use paymaster to sponsor! We’re also planning to hash paymasterId as add-on on top of our off-chain validation for it.
I have’t seen an issue which covers all above. Either cross chain replay or suggested paymaster nonce.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the paymaster's getHash function did not include the chain ID (and possibly the paymaster's own address and nonce) in the hashed data, allowing signatures to be valid across chains.
Impact
The paymaster could be tricked into sponsoring replayed operations on another chain, leading to financial loss for the paymaster; the user's funds are not directly at risk according to a commenter.
What the attacker needed
Paymaster deployed on multiple chains; same verifyingSigner on those chains; attacker can submit a user operation
The fix
The getHash function should include the chain ID (and ideally the paymaster's address and a per-wallet nonce) in the hashed data to prevent cross-chain replay.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A paymaster is a service that pays transaction fees for users. When a user signs an operation, the paymaster also signs a hash to approve it. Because that hash did not include the chain ID, the same signed operation could be used on another blockchain where the paymaster operates, letting an attacker get free transactions at the paymaster's expense.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.