AI Agents · ERC-4337 · Account Abstraction

AI Agent Smart Contract Audit

Quick Answer

  • AI agent smart contract audits review ERC-4337 account abstraction infrastructure: paymaster security, UserOperation validation, session key delegation scope, bundler trust assumptions, and autonomous agent over-permissioning.
  • The primary risk is over-delegation — agents granted more on-chain authority than their task requires. A compromised agent with unlimited token approvals and no contract allowlist can drain an entire wallet.
  • As AI agent frameworks (Coinbase AgentKit, Autonome) bring thousands of new on-chain agents, the ERC-4337 security surface is one of the fastest-growing audit categories. Free first scan, results in 60 seconds.

AI agents operating on-chain introduce a new class of smart contract security problem: the agent is not just code — it's a reasoning system that reads blockchain state, makes decisions, and executes transactions autonomously. The security of that system depends on how tightly the on-chain authority granted to the agent is scoped.

What AI Agent Audits Cover

Session Key Scope Review

Session keys grant agents limited signing authority. Audit ensures no-allowlist keys, unlimited value grants, or undated expiry can't be exploited if the agent's behavior is compromised.

Paymaster Validation Logic

Paymasters sponsor gas for agent operations. Validation gaps allow attackers to drain the Paymaster's ETH deposit by flooding it with sponsored UserOperations without the intended gatekeeping.

UserOperation Validation

Smart wallet validateUserOp must verify signatures, check nonces, and reject unauthorized operations. Gaps here — empty signature acceptance, cross-chain replay — allow unauthorized execution.

Agent Registry Security

Multi-agent systems use registries to define agent permissions and relationships. Registry admin access, agent enrollment logic, and permission upgrade paths are key attack surfaces.

Audit Your AI Agent Infrastructure Now

Paymaster logic, session key scope, UserOperation validation, and delegation security — free first scan.

AI Agent Smart Contract Vulnerability Classes

VulnerabilitySeverityDescriptionExample
Paymaster Drain AttackCriticalERC-4337 Paymasters sponsor gas fees for UserOperations. A Paymaster that validates sponsorship without strict per-user limits or allowlists can be drained by an attacker who crafts a flood of sponsored UserOperations that consume the Paymaster's deposited ETH without any corresponding value exchange. The Paymaster's stake in the EntryPoint gets consumed, disabling gas sponsorship for all legitimate users.A token-gated Paymaster that checks ERC-20 balance at validation time but doesn't burn or lock the tokens — an attacker with a flash-loaned balance passes validation for thousands of operations and drains the Paymaster's ETH deposit before the gas sponsorship is revoked.
UserOperation Validation BypassCriticalSmart contract wallets (ERC-4337 accounts) implement a `validateUserOp` function that must verify the caller's signature before execution. If validation logic has gaps — accepting empty signatures, failing to check nonces correctly, or allowing replay across chains — an attacker can execute arbitrary UserOperations on behalf of the wallet without authorization.A smart wallet that validates signature length but not signature content, accepting a 65-byte zero-padded byte array as a 'valid' ECDSA signature for any UserOperation targeting the wallet.
Autonomous Agent Over-DelegationHighAI agents operating on-chain via account abstraction are granted execution permissions through session keys or delegation contracts. Over-permissioned delegation — granting an agent scope to call arbitrary contracts, move unlimited token amounts, or act without time bounds — means a compromised agent model or malicious tool-use path can drain the entire wallet. Permission scoping is the primary security control for agentic systems.An AI agent granted a session key with unlimited USDC approval and no contract allowlist — if the agent's LLM backbone is prompted to call a malicious contract via tool use, the entire wallet balance is accessible.
Bundler Frontrunning and Simulation ManipulationHighERC-4337 Bundlers simulate UserOperations before including them in blocks. A malicious or compromised Bundler can frontrun profitable operations, selectively exclude operations from users it wants to grief, or manipulate simulation results to cause operations to fail at execution time after validation passed. This is particularly dangerous for AI agent workflows that depend on atomic execution sequences.A bundler that observes an AI agent's UserOperation to arbitrage a DEX price discrepancy, copies the profitable trade into a separate transaction executed in the same block before the agent's operation, then includes the agent's now-unprofitable operation to consume their gas.
Reentrancy via executeUserOp CallbackMediumERC-4337 account wallets execute arbitrary calls on behalf of their owner. If the execution path calls an external contract that can re-enter the wallet's execute function before the nonce is incremented, an attacker can reuse the same UserOperation authorization to execute additional operations. This is a chain-of-trust failure specific to the async execution model of smart wallets.A wallet's execute() function calls an external DeFi protocol that, before returning, calls back into the wallet's execute() function with a different calldata payload — re-entering before the nonce increment that would have prevented the second call.

AI Agent Audit — Frequently Asked Questions

What is an AI agent smart contract audit, and why is it different from a standard audit?
An AI agent smart contract audit reviews the security of on-chain infrastructure used by autonomous AI agents: smart contract wallets (ERC-4337), session key delegation systems, paymaster contracts, agent registry and registry authority patterns, and cross-agent communication contracts. Standard smart contract audits focus on logic correctness in isolated contracts. AI agent audits additionally assess the delegation scope granted to agents — how much on-chain authority the agent can exercise, under what conditions, and whether that authority can be abused if the agent's behavior is compromised by malicious inputs or adversarial prompts.
What is ERC-4337 and why is it the standard for AI agent infrastructure?
ERC-4337 is the Account Abstraction standard for Ethereum and EVM chains. It replaces the traditional externally-owned-account (EOA) model with smart contract wallets that can execute arbitrary logic on behalf of an owner. For AI agents, ERC-4337 is the infrastructure layer that allows: (1) gas sponsorship via Paymasters so agents don't need ETH to operate, (2) session keys that grant time-limited or action-limited permissions to autonomous agents, (3) multi-signature approval flows that require human confirmation for high-value operations, and (4) account recovery logic. The security of AI agents operating on-chain is largely the security of their ERC-4337 account configuration.
What are the biggest security risks for AI agents with on-chain access?
The highest-risk attack classes for AI agents are: (1) Over-delegation — agents granted broader on-chain scope than needed; a compromised agent can then drain funds or execute unauthorized operations. (2) Prompt injection via tool responses — if an agent reads on-chain data as part of its reasoning loop, a malicious smart contract can return data designed to manipulate the agent's actions. (3) Paymaster drain — paymasters that sponsor agent gas fees without strict limits can be exhausted by an attacker who crafts fake operations. (4) Session key expiry bypass — agents that don't check session key validity before executing can operate after their authorized window has closed.
How do session keys work, and what should they never allow?
Session keys are temporary signing keys granted to an agent with a defined scope: which contracts can be called, what token amounts can be moved, and how long the key is valid. They are stored off-chain by the agent and submitted as signatures in UserOperations. A session key's security is only as strong as its scope restrictions. Session keys should never allow: (1) calls to arbitrary contracts (requires an allowlist), (2) token approvals or transfers above a defined limit, (3) key delegation — the session key should not be able to grant further permissions, (4) access past an expiry timestamp. The most dangerous session key is one with no contract allowlist and no value limit.
How much does an AI agent smart contract audit cost?
AI agent audit scope depends on the number of contracts: a single ERC-4337 account wallet with a paymaster is typically $10,000–$30,000. A full agentic system with session key management, agent registry, multi-agent communication contracts, and paymaster infrastructure is $50,000–$150,000. As AI agent frameworks (Coinbase AgentKit, Autonome, LangChain on-chain plugins) proliferate, security firms that specialize in account abstraction security — including OpenZeppelin and Spearbit — command a premium for AI agent reviews. SmartContractAuditor.ai provides instant analysis for paymaster logic, session key scope, UserOperation validation, and delegation patterns — free for the first scan.
Written by Duron Epps, Founder of SmartContractAuditor.ai · Last updated July 2026