# ERC-4337 Security: EntryPoint Rules & Paymaster Griefing

> Audit ERC-4337 EntryPoint v0.7 simulation-vs-execution divergence, ERC-7562 banned opcodes/storage slots, and VerifyingPaymaster postOp gas-drain griefing.

Canonical: https://nftvenueledger.com/protocols/erc-4337-entrypoint-paymaster-userop-validation-griefing
Last updated: 2026-11-14T19:40:06.293Z

**Publication:** NFTVenue Ledger
**Category:** Erc721 Erc1155 Eip712 Permit Security
**Published:** 2026-11-13T21:05:25.915Z
**Author:** Dr. Devon Kurosawa, PhD (PhD in Distributed Systems & Cryptographic Protocol Verification)
**Reviewer:** Not recorded

## Answer-first summary

Because ERC-4337 bundlers pay L1/L2 gas upfront for untrusted UserOperations, strict ERC-7562 opcode and storage-access sandboxing prevents mass mempool invalidation DoS.

## Key takeaways

- ERC-7562 forbids unstaked accounts and paymasters from reading volatile block opcodes (TIMESTAMP, BASEFEE) or external unassociated storage slots during UserOp validation.
- ERC20Paymasters must pull maxTokenCost upfront during validatePaymasterUserOp and refund excess in postOp—otherwise malicious callData can revoke ERC-20 allowance mid-tx.
- EntryPoint v0.7 introduces PackedUserOperation (-35% calldata bytes) and a 10% surcharge on unused execution gas exceeding 40,000 units to prevent bundler block-stuffing.
- ERC-4337 splits 256-bit nonces into a 192-bit parallel channel key plus a 64-bit sequential counter, enabling concurrent independent automation lanes.

## Related financial entities

- **Checks-Effects-Interactions (CEI) Security Pattern** (CEI-SEC) — product: Foundational programming design pattern in smart contract development preventing reentrancy attacks by executing internal state updates before external calls.
- **EIP-712 Typed Structured Data Standard** (EIP-712) — product: Standard for hashing and signing of typed structured data as opposed to just arbitrary byte strings, providing human-readable authorization.
- **Seaport Marketplace Protocol Standard** (SEAPORT) — product: Open-source, highly optimized marketplace contract suite for efficiently buying and selling fungible and non-fungible tokens.

## Analysis

In classic Ethereum, validating an EOA transaction requires checking one fixed `ecrecover` signature and one account balance/nonce—taking microseconds and zero arbitrary EVM execution. **ERC-4337 Account Abstraction** (`EntryPoint v0.7 at 0x0000000071727De22E5E9d8BAf0edAc6f37da032`) turns signature and gas-payment validation into **arbitrary Turing-complete smart-contract execution** inside `validateUserOp` and `validatePaymasterUserOp`!

Anchored in our [EIP-712, Permit2 & proxy security master guide](/protocols/eip712-permit2-erc721-royalty-proxy-timelock-security-2026), an immediate Asymmetric DoS Trap arises: **what stops an attacker from submitting 1,000 `PackedUserOperation`s that pass off-chain bundler `eth_estimateUserOperationGas` simulation, then flip one shared storage variable on-chain so all 1,000 UserOps revert inside `handleOps`—sticking the Bundler with zero reimbursement**?

## ERC-7562 Validation Sandboxing: Banned Opcodes & Associated Storage

ERC-4337 and **ERC-7562** eliminate simulation-to-execution invalidation vectors by strictly partitioning every `handleOps` call into an isolated **Validation Phase** followed by an **Execution Phase**:

1. **Banned Environment Opcodes During Validation**: Unless an entity (`Factory, Account, Paymaster`) stakes native ETH inside `EntryPoint`, calling volatile environment opcodes—`TIMESTAMP`, `NUMBER`, `COINBASE`, `PREVRANDAO`, `BASEFEE`, `GASPRICE`, `BLOBBASEFEE`—during `validateUserOp` is **strictly forbidden** by bundler tracers! (Time-bounded signatures must return `validAfter` and `validUntil` inside packed `validationData` so `EntryPoint` checks `block.timestamp` deterministically!)
2. **Associated Storage Isolation**: Unstaked smart accounts may touch **only storage slots belonging to `address(account)` itself** (or `keccak256(abi.encode(account, slot))` associated mapping slots in external ERC-20 contracts), preventing 1,000 attacker accounts from reading one shared "kill-switch" contract slot!

![ERC-4337 EntryPoint v0.7 two-phase validation and execution loop with Paymaster gas sponsorship](/api/figure?type=flow&title=ERC-4337%20EntryPoint%20v0.7%20Validation%20%26%20Sponsorship%20Loop&subtitle=Strict%20phase%20separation%20protecting%20Bundlers%20and%20Paymasters%20from%20simulation-execution%20divergence&steps=1.%20ERC-7562%20Trace%3A%3ABundler%20simulates%20validateUserOp%3B%20rejects%20banned%20opcodes%2Fslots%7C2.%20On-Chain%20Validate%3A%3AEntryPoint%20verifies%20account%20%2B%20Paymaster%20sigs%20%26%20prefund%20deposit%7C3.%20Inner%20Execution%3A%3AEntryPoint%20invokes%20account.executeUserOp%28callData%29%20in%20try-catch%7C4.%20Paymaster%20postOp%3A%3ASettle%20ERC-20%20gas%20fee%20%2B%20apply%2010%25%20unused%20execution%20gas%20penalty&metrics=ENTRYPOINT%20V0.7%3A%3A0x0000..da032%3A%3APackedUserOperation%20calldata%20savings%7CUNUSED%20GAS%20PENALTY%3A%3A10%25%20Above%2040k%3A%3Av0.7%20anti-overestimation%20bundler%20shield%7CVALIDATION%20DATA%3A%3Auint256%20Packed%3A%3Aaggregator%20%2820B%29%20%2B%20validUntil%20%286B%29%20%2B%20validAfter%20%286B%29%7CSTAKE%20UNLOCK%3A%3A%3E%3D%201%20Day%20Delay%3A%3ASlashed%2Fthrottled%20on%20mempool%20DoS)

## Three Critical Paymaster & Smart-Account Bugs in DeFi / NFT Venues

Integrating sponsored gasless onboarding across consumer NFT drops and DEXs in our [marketplaces directory](/marketplaces) (such as [Basepaint](/marketplaces/basepaint), [Alts By Adidas](/marketplaces/alts-by-adidas), and [Art Blocks X Bright Moments](/marketplaces/art-blocks-x-bright-moments)) exposes custom **`ERC20Paymaster`** and **`VerifyingPaymaster`** contracts to three classic exploits:

- **Exploit 1 — `userOpHash` Omission of `chainId` or `entryPoint` in Custom Signers**: Always verify signatures over `entryPoint.getUserOpHash(userOp)`, which commits to `(packedUserOp, address(entryPoint), block.chainid)`—never hash raw `userOp.callData` alone!
- **Exploit 2 — ERC-20 Paymaster Approval Revocation inside `execute` (`postOp Griefing`)**: Suppose an `ERC20Paymaster` checks `USDC.allowance(user, paymaster) >= maxCost` during `validatePaymasterUserOp`, intending to pull `USDC` inside `postOp`. During Step 3 (`execute`), the malicious user's `callData` calls `USDC.approve(paymaster, 0)`! In EntryPoint v0.6, a reverting `postOp` caused a dual-pass retry trap; in **v0.7**, `ERC20Paymaster`s must either **escrow `maxCost` upfront inside `validatePaymasterUserOp`** and refund the delta in `postOp`, or account for reverted execution cleanly!
- **Exploit 3 — Inflated `callGasLimit` Bundler Starvation**: Prior to v0.7, attackers set `callGasLimit = 5,000,000` while consuming only `30,000` gas, packing a block with empty gas reservations so bundlers earned near-zero fees. EntryPoint v0.7 charges a **`10%` penalty on unused execution/postOp gas exceeding `40,000` gas**!

## ERC-4337 v0.6 vs EntryPoint v0.7 Security Upgrades

| Security / Gas Dimension | Legacy EntryPoint v0.6 | Audited EntryPoint v0.7 | Security & Cost Impact |
| :--- | :--- | :--- | :--- |
| UserOperation Struct Layout | 11 separate 32-byte fields | **`PackedUserOperation`** (`bytes32 accountGasLimits`) | **-18% to -28% L2 calldata gas** |
| Unused `callGasLimit` Griefing | Unpenalized reservation bloat | **`10%` charge on unused gas `> 40k`** | Stops bundler block-space starvation |
| `postOp` Second-Pass Attack | Complex `postOpReverted` double-run | **Single clean execution + `postOpGasLimit`** | Eliminates Paymaster drainage edge cases |
| ERC-4337 Module Isolation | Ad-hoc plugin hooks | **ERC-7579 Modular Smart Accounts** | Standardized Validator/Executor boundaries |

![L2 transaction cost and bundler DoS surface reduction from ERC-4337 EntryPoint v0.6 to v0.7](/api/figure?type=bars&title=EntryPoint%20v0.7%20Calldata%20Compression%20%26%20Security%20Bounds&subtitle=L1%20data%20posting%20overhead%20and%20gas-limit%20enforcement%20across%20UserOperation%20lifecycles&steps=v0.6%20Unpacked%20UserOp%3A%3A~890%20bytes%20calldata%3B%20vulnerable%20to%20unused%20callGasLimit%20bloat%7Cv0.7%20PackedUserOperation%3A%3A~580%20bytes%20calldata%20%28-35%25%20L1%20blob%2Fcalldata%20cost%20on%20Rollups%29%7CVerifyingPaymaster%20Escrowed%3A%3AOff-chain%20ECDSA%20sponsorship%20with%20validUntil%20%3C%3D%20%2B300s%7CERC-20%20Pre-Charge%20Paymaster%3A%3APulls%20maxTokenCost%20in%20validate%3B%20refunds%20unused%20delta%20in%20postOp&metrics=CALLDATA%20REDUCTION%3A%3A-35%25%20Bytes%3A%3APacked%20gas%20limits%20%26%20paymasterAndData%7CPOSTOP%20GAS%20FLOOR%3A%3AExplicit%20Cap%3A%3ADedicated%20paymasterPostOpGasLimit%7CNONCE%20CHANNELS%3A%3A192-Bit%20Key%20%2B%2064b%3A%3AParallel%20UserOp%20execution%20lanes%7CMODULAR%20SPEC%3A%3AERC-7579%3A%3AAudited%20Validator%20%2F%20Hook%20%2F%20Fallback)

## EntryPoint v0.7 Prefund & 10% Unused-Gas Penalty Formula

Auditors verify that both `SmartAccount` and `Paymaster` calculate `requiredPreFund` accurately, accounting for v0.7's packed `accountGasLimits` and `10%` unused gas surcharge:

```formula
EntryPoint v0.7 Packed Gas Accounting & Unused-Gas Anti-Griefing Surcharge:
 1) Unpacking PackedUserOperation Gas Fields:
 verificationGasLimit = uint128(bytes16(accountGasLimits))
 callGasLimit = uint128(uint256(accountGasLimits))
 maxPriorityFeePerGas = uint128(bytes16(gasFees))
 maxFeePerGas = uint128(uint256(gasFees))

 2) Maximum Upfront EntryPoint Deposit Lock (requiredPreFund):
 maxGas = preVerificationGas + verificationGasLimit + callGasLimit + paymasterVerificationGasLimit + paymasterPostOpGasLimit
 maxPreFund = maxGas * maxFeePerGas

 3) v0.7 Unused Execution Gas Penalty (Blocks Block-Stuffing DoS):
 unusedGas = callGasLimit - actualExecutionGasUsed
 surcharge = (unusedGas > 40,000) ? (0.10 * unusedGas) : 0
 finalBill = (actualTotalGas + surcharge) * min(maxFeePerGas, block.basefee + maxPriorityFeePerGas)

Worked ERC20Paymaster Escrow Check ($3,000 ETH, 0.05 gwei L2 gas, maxGas = 400,000):
 Paymaster locks 0.06 USDC upfront during validatePaymasterUserOp; actual swap uses 180,000 gas (unused = 70k -> +7k penalty)
 => postOp refunds 0.031 USDC cleanly; even if user revokes USDC allowance inside execute, Paymaster loses $0.00!
```

## Convergence With Pectra EIP-7702 Native EOA Delegation

With Ethereum's Pectra upgrade introducing **EIP-7702**, existing EOAs can temporarily or persistently point their codehash to an ERC-4337 smart-account implementation without migrating assets—creating a fierce new phishing battleground analyzed next in [EIP-7702 EOA code delegation security](/protocols/eip-7702-eoa-code-delegation-sweeper-phishing-mitigation) and [ERC-1271 signature replay](/protocols/erc-1271-smart-contract-wallet-signature-replay-across-safes) inside our [EIP-712, Permit2 & Proxy Security hub](/topics/erc721-erc1155-eip712-permit-security).

## Frequently asked questions

### Why does ERC-4337 ban block.timestamp inside validateUserOp?

If validateUserOp checked require(block.timestamp < X) directly, an attacker could craft thousands of UserOps that pass off-chain simulation at t = X - 1 and all revert at t = X, exhausting bundler resources without paying gas; instead, accounts return validUntil for EntryPoint to check.

### How can a malicious user drain a poorly written ERC-20 Paymaster?

If the Paymaster only checks USDC.allowance in validation and waits until postOp to call transferFrom, the user execution step can call USDC.approve(paymaster, 0) or transfer away their USDC so postOp fails to collect payment.

### Why did EntryPoint v0.7 add a 10% penalty on unused callGasLimit?

Bundlers reserve block gas capacity based on declared callGasLimit; without a penalty, attackers reserved millions of unused gas units per UserOp to starve bundlers of priority-fee revenue.

### How do parallel nonces work in ERC-4337 EntryPoint?

EntryPoint getNonce(sender, uint192 key) maintains an independent 64-bit sequence counter for every 192-bit key, allowing a DeFi session key on lane #1 to execute without colliding with user swaps on lane #0.


## Source URLs

- https://eips.ethereum.org/EIPS/eip-4337
- https://eips.ethereum.org/EIPS/eip-7562
- https://github.com/eth-infinitism/account-abstraction/releases/tag/v0.7.0

## Citation

- APA: Dr. Devon Kurosawa, PhD. (2026). ERC-4337 Account Abstraction Security: EntryPoint Storage Rules & Paymaster Griefing. NFTVenue Ledger. https://nftvenueledger.com/protocols/erc-4337-entrypoint-paymaster-userop-validation-griefing
- Canonical article: [ERC-4337 Account Abstraction Security: EntryPoint Storage Rules & Paymaster Griefing](https://nftvenueledger.com/protocols/erc-4337-entrypoint-paymaster-userop-validation-griefing)
- Site research index: [NFTVenue Ledger](https://nftvenueledger.com/llms-full.txt)
