Attacks on ERC-4337 Paymasters

ERC-4337 paymaster attacks manipulate gas estimation or exploit reentrancy to drain the sponsorship treasury

SECURITY4 min readBy AlgoSys Editorial TeamPublished Apr 24, 2026Updated Jun 26, 2026
Contents

Paymaster contracts (a paymaster is a gas sponsor) are an integral part of account abstraction under the ERC-4337 standard: they pay the gas fee on behalf of the user, making transactions gasless. That is precisely what makes them an attractive target. An attacker who finds a vulnerability in this logic can drain funds or disrupt service. In essence, an attack undermines the trust placed in the paymaster, which is responsible for managing funds honestly and accurately on behalf of others' transactions.

Account abstraction is still a new technology, but the potential for exploits is already significant. Attack vectors typically rely on complex interactions between the paymaster, user operations, and the underlying smart contracts. Direct high-profile incidents targeting paymasters specifically have been few, but well-known DeFi disasters clearly illustrate the scale of risk posed by sophisticated contract manipulation: the Ronin bridge hack (2022) and Multichain (2023) are instructive examples.

The attacker's goal is straightforward. The attacker wants to make the paymaster's logic approve an unauthorized withdrawal of funds or generate inflated costs that then fall on the paymaster's treasury or on honest users. The result is direct financial losses for the operator and indirect harm from service disruptions and reputational damage.

MECHANICS

The most common scenario is manipulation of the gas estimation or fee calculation logic inside the contract. The attacker submits a user operation that looks entirely legitimate, but when processed by the paymaster it triggers an unexpectedly high gas cost due to a bug in the formula. The paymaster, programmed to cover these fees, dutifully pays the inflated amount, unaware it has been deceived.

The second method exploits reentrancy vulnerabilities (calling a function again before the previous call finishes) or weak access control. If the paymaster interacts with untrusted contracts without proper checks, the attacker can inject a callback function that drains funds before the original transaction finishes. This is a direct analog of the classic reentrancy attacks that have burned DeFi protocols repeatedly.

Finally, the attacker can exploit specific ERC-4337 features such as simulateUserOperation (operation simulation) and validateUserOperation (operation validation). If these verification stages are not sufficiently robust, the attacker constructs an operation that bypasses security checks and forces the paymaster to sponsor a malicious transaction. In practice this often comes down to substituting the nonce (operation counter) or manipulating the signature verification.

RED FLAGS

The indicators listed below do not individually prove an attack, but together they form an alarming picture. If you see several at once, it is worth pausing the contract and investigating.

  • The fee calculation logic in the contract looks unusually complex or opaque.
  • Critical functions such as withdraw (withdrawal) or setGasLimit (gas limit setting) have insufficient access control.
  • Transaction simulations produce unpredictable or excessively high gas costs for seemingly simple operations.
  • External calls inside the paymaster are not protected against reentrancy and do not validate input data.
  • The contract has no audit or formal verification, or they are incomplete.
  • Monitoring records frequent small-value transfers from the paymaster to unknown addresses.
  • The interface shows inconsistent fee estimates or warnings on sponsored transactions.

PROTECTION

Start with access control. All critical functions must be accessible only to authorized parties, and administrative actions are best placed behind a multisig wallet (requiring multiple signatures) to distribute control and eliminate a single point of failure.

Next comes independent code review. Commission a thorough security audit from reputable firms specializing in smart contracts and ERC-4337, and supplement it with formal verification, which mathematically proves the absence of critical vulnerabilities.

Calculation logic must be made resistant to manipulation: use gas limit and price oracles that are hard to fake, and build in circuit breakers (auto-stops on suspicious activity) that can instantly pause the paymaster. Design the contract itself with reentrancy protection, for example OpenZeppelin's ReentrancyGuard, direct all external calls only to whitelisted and audited contracts, and thoroughly validate the data of every user operation before agreeing to sponsor it.

Finally, real-time observation. Connect blockchain analytics tools and set up alerts for unusual transaction volumes, fee spikes, and unexpected contract interactions.

To make this concrete, consider a simplified example of a fee manipulation attack compared to a legitimate operation.

Parameter Legitimate operation Fee manipulation attack
Declared gas approximately 80,000 units approximately 80,000 units
Actual charge approximately 80,000 units 5,000,000 units due to a formula bug
Recipient address known service contract unknown attacker address
Frequency one-time repeated across dozens of operations
Who paid the user effectively for free, difference covered by the treasury normally the paymaster treasury, drained within hours

How to tell an attack from a legitimate fee spike: a legitimate gas increase is explainable (a complex operation, a congested network) and does not recur systematically. An attack is revealed by three things together: an inflated charge on a simple operation, systematic repeatability, and an outflow of funds to addresses not on the whitelist. If you see all three, do not wait for confirmation, pause the contract.

AFTERMATH

The first priority is stopping the fund outflow. Immediately pause all operations of the compromised paymaster: pause the contract or revoke its right to sponsor transactions so the treasury stops draining.

Then ensure transparency. Notify users and the community through official channels, describing the situation and the progress of the investigation honestly, so as not to fuel rumors and panic.

At the same time, bring in professionals. Engage blockchain security firms (for example Chainalysis, PeckShield, or SECOR) for incident response and forensic analysis, and also report the incident to the relevant law enforcement agencies and cybercrime units.

Finally, work on asset recovery. Trace stolen funds on-chain, explore legal avenues for their return, and if necessary activate insurance policies or community-managed recovery funds.

FAQ

What is a paymaster contract in ERC-4337?

A paymaster is a smart contract that pays the gas fee on behalf of the user. It makes a transaction gasless for the end user: they do not need to hold the network's native token or understand the mechanics of gas payment. The contract takes on that complexity, and the user simply signs the operation.

Can a paymaster attack bankrupt an entire protocol?

Yes. A successful attack can completely drain the paymaster's treasury, from which gas is paid. Once the sponsorship funds run out, the protocol loses the ability to serve transactions, and the operator suffers direct financial losses. That is why securing a paymaster is considered critically important.

How does account abstraction relate to paymaster security?

Account abstraction via the ERC-4337 standard introduces the paymaster as a key component of the entire scheme. The robustness of an account abstraction implementation therefore depends directly on how well the paymaster is secured: a vulnerability in the paymaster becomes a vulnerability in the whole system.

How does a paymaster attack differ from an ordinary fee calculation bug?

An ordinary bug leads to a one-time incorrect charge and is usually noticed immediately. An attack is deliberate exploitation: the attacker constructs a user operation so that it passes validation over and over and keeps draining funds. The main tells that it is an attack are repeatability, a systematic outflow of funds to unknown addresses, and sharp fee spikes on simple operations.

What is a reentrancy attack as applied to a paymaster?

Reentrancy occurs when the paymaster contract, during its own execution, calls an external untrusted contract that manages to call back into the paymaster before the first transaction finishes. This allows the attacker to withdraw funds multiple times in a row. Protection is built on the ReentrancyGuard pattern and restricting all external calls to a whitelist of verified contracts.

What should be done first if a paymaster is compromised?

Immediately stop the contract: pause it or revoke its right to sponsor transactions so that the fund outflow ceases. Only after that does it make sense to notify users, engage security firms for forensics, and trace stolen funds on-chain.

Put this to work in the terminal

Live charts, derivatives, on-chain and macro data, free.

Open terminal →