Research
PACE: Policy-Attested Contract Execution for Safe AI Agents in Decentralized Finance
Autonomous AI agents built on large language models are starting to execute real DeFi actions — swaps, lending operations, yield management — but they inherit the LLM's vulnerability to prompt…

- arXiv
- 2608.17220
- Published
- 2026-08-18
- Authors
- Rabimba Karanjai, Yang Lu, Richard Williamson, Hemanth Hm, Prakhar Mehrotra, Lei Xu, Weidong, Shi
AI summary
Overview
Research area: Blockchain security / AI agent safety — specifically, transaction-level authorization for large-language-model agents that act in decentralized finance (DeFi).
Technical level: Intermediate. The paper assumes some familiarity with smart contracts, ERC-20 approvals, and prompt injection, but its central argument is architectural and can be followed without deep cryptography background.
Scope: The paper proposes and evaluates PACE (Policy-Attested Contract Execution), a three-layer guardrail that sits between an LLM agent and on-chain execution, and measures its safety, false-positive, and gas-overhead behaviour on a 40-task, 2,800-trial deterministic sandbox benchmark plus separate live-LLM and local-EVM studies.
What This Paper Is About
Autonomous AI agents built on large language models are starting to execute real DeFi actions — swaps, lending operations, yield management — but they inherit the LLM's vulnerability to prompt injection, and a hijacked agent's transaction settles on-chain irreversibly. Existing safeguards each cover a fragment: model-level defences are probabilistic, simulation previews are not bound to the bytes actually broadcast, and on-chain wallet guards never ingest an attested off-chain simulation.
The paper's goal is to make the safety of an agent's action independent of the trustworthiness of the model that proposed it: reduce every action to a typed object, check it with a deterministic verifier that never consults the LLM, and cryptographically bind that decision to the exact execution bytes, re-verified on-chain before any external call.
Key Contributions
- The PACE architecture — a pipeline combining typed transaction intents, a deterministic policy verifier, signed Policy Decision Records (PDRs), and a Solidity smart account that re-checks the PDR on-chain before executing.
- A 40-task benchmark across four attack categories (prompt injection, unsafe contracts, DeFi exploit patterns, MEV/slippage) plus benign utility as a negative control, with eight tasks each, evaluated against six non-PACE baselines plus PACE.
- Deterministic sandbox experiments (2,800 trials, 10 seeds, 7 agents) showing PACE achieves a 0.00 unsafe execution rate with a 0.00 false-positive rate, plus ablation studies identifying permissive policy settings (+57.5 pp) and the touched-contract allowlist (+12.5 pp) as the dominant safety components.
- A Solidity smart account with measured gas overhead of 29,826–31,822 gas per transaction, alongside separate live-LLM (three models) and local-EVM evidence and a reproducible artifact invoked via
make reproduce.
Main Findings
- PACE eliminates unsafe execution in the benchmark: 100.0% correct rate (40/40 per seed), 0.00 unsafe execution rate, 0.00 false-positive rate, and a dangerous block rate of 1.00 over 2,800 trials.
- The unguarded baseline is far worse: the Raw agent, which executes every intent, reaches a 20.0% correct rate, a 0.80 unsafe execution rate over all trials, a 1.00 attack success rate over attack trials, and a 0.00 dangerous block rate.
- Partial defences leave gaps: Prompt-Only reaches 41.2% correct (with seed-level variability of ±2.56 pp, unsafe execution 0.5875 ± 0.0256, attack success 0.7344 ± 0.0320); Sim-Only 27.5% correct; WalletGuard 75.0% correct with 0.25 unsafe execution; StaticGuard 95.0% correct with 0.05 unsafe execution; and SimGuard — the strongest non-PACE baseline — 97.5% correct with an attack success rate reported in the text as 0.0312.
- Calldata binding is the decisive component: SimGuard applies policy plus a fresh simulation but omits hash-equality binding, and consequently admits exactly one attack — the calldata-mutation task
da_08. PACE rejects it off-chain viaintent_hashand independently on-chain viakeccak256(data); it is the only task freed when calldata binding is removed. - The policy itself dominates safety: in a 320-trial ablation (8 PACE variants, seed 42), a permissive policy raises the unsafe execution rate from 0.000 to 0.575 (+57.5 pp); removing the touched-contract allowlist raises it to 0.125 (+12.5 pp); skipping simulation to 0.050 (+5.0 pp); removing calldata binding or freshness enforcement to 0.025 (+2.5 pp each); removing metadata scanning shows no isolated impact.
- Thresholds trade false positives against admitted attacks: accuracy peaks at a 100 bps slippage threshold (100.0%) and drops at 10 bps (95.0%, over-rejection) and 1,000 bps (95.0%, MEV admitted); a 0-second freshness window drops accuracy to 80.0%, while windows of at least 1 second recover 100.0%.
- On-chain overhead is material for cheap operations: PDR verification adds 29,826–31,822 gas (Foundry, Solidity 0.8.24, optimizer 200 runs), dominated by
ecrecover(~3,000) and nonce SSTORE (~20,000) — 91.7% relative cost for an approval, 78.9% for a transfer, and 50.5% for a swap. Verifier-only decision latency is ~0.04 ms and excludes trace-based simulation, ABI decoding, and archive-RPC access. - Live LLMs still hit a zero floor, but with new false positives: across gemini-3.1-flash-lite, DeepSeek-V4-Flash, and gpt-4o (5 repeats, 595 trials, 160 attack / 40 benign per model, seed 42), the PACE-guarded attack-success rate is 0.000 for all three; correct rates are 97.5, 97.4, and 99.0 respectively, and benign false-positive rates are 0.125, 0.128, and 0.050. Unguarded, gpt-4o judged 11/160 attack trials (6.9%) and DeepSeek-V4-Flash 4/156 (2.6%) safe, and the verifier rejected all of them; gemini-3.1-flash-lite admitted none unguarded.
- Adaptive evasion fails, but policy-valid harm succeeds: against a policy-aware adversary (seed 0), PACE blocks 8/8 evasion attacks while SimGuard and StaticGuard block 7/8 and WalletGuard 2/8 — but PACE and every baseline admit all 8/8 policy-valid-but-harmful transactions, including a five-leg multi-transaction drain whose legs each stay under the cap.
- Per-seed attack blocking counts (of 32): Raw 0, Sim-Only 3, WalletGuard 22, StaticGuard 30, SimGuard 31, PACE 32.
- The local EVM enforcement path passes 11/11 smart-account cases: three valid PDR executions, seven invalid-PDR rejections (calldata mutation, target mutation, replay, expiry, wrong verifier/account/chain ID), and one owner-only raw execution path.
Methodology in Plain English
The researchers place a checkpoint between the AI agent and the blockchain. The agent cannot submit a transaction directly; it must first describe its intended action in a rigid, typed format — target address, value, calldata, token approvals, slippage tolerance. That description is hashed so it can be referenced later.
Before the action is approved, it is run through a simulator so the framework can see what it would touch and what the resulting state would look like. Then a deterministic verifier — a pure, stateless function that never queries the model — compares the intent and the simulation report against a user-written policy: which addresses, functions, and tokens are allowed, what value and spend caps apply, whether unlimited approvals are banned, what slippage is acceptable, which function names are blocked, and how fresh a simulation must be.
If the intent passes, the verifier signs a Policy Decision Record that binds the intent, policy, simulation, and calldata hash together with a nonce and validity window. A Solidity smart account on-chain recovers that signature and re-checks nine conditions before making any external call, consuming the nonce first so a re-entrant call cannot replay it.
For evaluation, the authors built an in-memory DeFi simulator with ERC-20 tokens, a constant-product AMM (30 bps fee, 10,000 WETH / 10,000,000 DAI reserves), a lending pool with an oracle-based health factor (price 1,000 DAI/ETH, loan-to-value 0.75, liquidation threshold 0.80), a malicious router, and an approval drainer. They compared seven agents ordered by safety coverage — Raw, Prompt-Only, Sim-Only, WalletGuard, StaticGuard, SimGuard, and PACE — across 40 tasks and 10 seeds. Deterministic runs use a regex-based mock LLM so results are reproducible without API keys. Separately, they ran three real LLMs through the same verifier, and ran the smart account in Foundry against local bytecode.
Why This Matters
Impact on research: The paper reframes agent safety as a property of the policy and verifier rather than of the model, and it explicitly separates soundness (any executed transaction provably satisfies the declared policy) from completeness (whether the policy captures every unsafe outcome). That distinction, together with the ablation showing a permissive policy costs 57.5 pp, gives the field a concrete measurement target: policy authoring, not model hardening, is where the safety budget goes.
Real-world applications:
- Custodial or brokerage-facing agent wallets that execute user-directed DeFi strategies while guaranteeing the agent cannot exceed declared limits.
- Smart-account modules (ERC-4337 / Safe-style) that add an attested off-chain simulation check to existing spending-cap and allowlist guards.
- Transaction-security and simulation services (the paper cites Tenderly, Blockaid, and Wallet Guard) supplying the
SimulationReportthat a deterministic on-chain verifier then binds to execution bytes. - Defensive benchmarking for teams deploying tool-using agents under real capital, using the released synthetic attack suite before going live.
Industry relevance: The authors are affiliated with the University of Houston, PayPal, and Kent State University, and the framing is explicitly deployment-aware — gas costs broken out per operation type (91.7% for an approval, 78.9% for a transfer, 50.5% for a swap), an owner-only recovery path, and a roadmap for expressing the PDR verifier as a standard validator/hook module rather than a bespoke account.
Future Directions
- Adaptive adversaries that learn: the current adaptive study gives the attacker full policy knowledge for a single round; attackers that learn against the verifier over many rounds, and multi-step agent loops that compose individually policy-valid legs into a harmful sequence, remain open and are called the most important next target.
- Higher-fidelity execution: running the full attack suite under trace-based simulation against forked mainnet state, and broadening coverage to cross-contract reentrancy, governance, and bridge exploits. The mainnet-fork harness exists but makes no result claims unless
results/fork_study/results.csvis generated. - Field provenance and ABI decoding: soundness requires that the typed fields (approvals, spend, slippage, touched contracts) be reconstructed from decoded calldata and the trace by trusted code rather than trusted from the LLM; full ABI decoding of arbitrary router calldata is delegated to the trace backend.
- Standardization and tooling: upgrading PDR hashing to EIP-712 typed data, integrating validation into the ERC-4337
validateUserOppath, and building tools for authoring and tuning policies — plus larger model panels including open-weight models and end-to-end agent harnesses.
Target Audience
Smart-contract and wallet-security engineers building agent-facing custody or smart-account products; AI safety researchers studying tool-using agents and prompt injection; DeFi protocol teams evaluating guardrails before letting agents touch real capital; and policy or risk reviewers who need to understand precisely what a "deterministic safety floor" does and does not guarantee. Readers seeking production-ready DeFi security should note the authors' own framing: results are logic-level safety within a reproducible benchmark on a simplified in-memory simulator and a regex-based mock LLM, not deployment-grade assurance against adaptive adversaries on live chains.
Authors’ abstract
Autonomous AI agents are emerging as interfaces for decentralized finance (DeFi) actions such as swaps, lending operations, and yield management. Because these agents rely on large language models (LLMs) to plan transactions, they inherit the LLM's susceptibility to prompt injection and lack of mechanisms to bind a verifier's approval to the exact transaction ultimately submitted on-chain. We present PACE (Policy-Attested Contract Execution), a transaction-level…
The full abstract on arXiv