Paymaster ETH can be drained with malicious sender
The paymaster's signature can be replayed because the sender contract can be upgraded to a malicious version that ignores nonces, allowing the same signed transaction to be submitted repeatedly. An attacker could drain the paymaster's deposits by repeatedly using a previously valid signature.
Submitted by taek
Paymaster’s signature can be replayed to drain their deposits.
Proof of Concept
Scenario :
- user A is happy with biconomy and behaves well biconomy gives some sponsored tx using verifyingPaymaster — let’s say paymaster’s signature as sig X
- user A becomes not happy with biconomy for some reason and A wants to attack biconomy
- user A delegate calls to Upgrader and upgrade it’s sender contract to MaliciousAccount.sol
- MaliciousAccount.sol does not check any nonce and everything else is same to SmartAccount(but they can also add some other details to amplify the attack, but let’s just stick it this way)
- user A uses sig X(the one that used before) to initiate the same tx over and over
- user A earnes nearly nothing but paymaster will get their deposits drained
files : Upgrader.sol, MaliciousAccount.sol, test file https://gist.github.com/leekt/d8fb59f448e10aeceafbd2306aceaab2
Tools Used
hardhat test, verified with livingrock
Recommended Mitigation Steps
Since validatePaymasterUserOp function is not limited to view function in erc4337 spec, add simple boolean data for mapping if hash is used or not
mapping(bytes32 => boolean) public usedHash
function validatePaymasterUserOp(UserOperation calldata userOp, bytes32 /*userOpHash*/, uint256 requiredPreFund)
external override returns (bytes memory context, uint256 deadline) {
(requiredPreFund);
bytes32 hash = getHash(userOp);
require(!usedHash[hash], "used hash");
usedHash[hash] = true;
livingrockrises (Biconomy) confirmed, but commented:
Unhappy with the recommendation.
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 validation function does not track whether a signature has already been used, and the sender contract can be upgraded to bypass nonce checks.
Impact
An attacker could drain the paymaster's deposits by replaying a valid signature multiple times.
What the attacker needed
A sponsored transaction signature from the paymaster; ability to upgrade the sender contract
The fix
The paymaster should track used signatures and reject any replay, for example by storing a hash of each user operation and checking it has not been used before.
How it was found
- User A receives a sponsored transaction using the verifying paymaster, obtaining a signature.
- User A upgrades their sender contract to a malicious account that does not check nonces.
- User A reuses the same signature to initiate the same transaction repeatedly.
- The paymaster's deposits are drained as it pays for each repeated transaction.
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. The paymaster signs a message to approve a specific transaction, but if that signature can be reused many times, the paymaster ends up paying fees over and over. Here, a user can upgrade their wallet to a malicious version that ignores the usual one-time-use protection, so the same signed transaction can be submitted repeatedly.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.