Skip to content
Business logic Audit finding Intermediate

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.

taek Follow

Originally disclosed on Code4rena

Submitted by taek

contracts/smart-contract-wallet/paymasters/verifying/singleton/VerifyingSingletonPaymaster.sol#L97-L111

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.


The original report as published on Code4rena, by taek. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. User A receives a sponsored transaction using the verifying paymaster, obtaining a signature.
  2. User A upgrades their sender contract to a malicious account that does not check nonces.
  3. User A reuses the same signature to initiate the same transaction repeatedly.
  4. 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.

More from Biconomy - Smart Contract Wallet contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.