Building Trustless AI Agents: ERC-8004 Security Audit Guide

marsbitPublished on 2026-03-05Last updated on 2026-03-05

Abstract

ERC-8004, the Trustless Agents standard deployed on Ethereum, introduces a verifiable and trust-minimized framework for AI Agent identity and reputation management through three core registries: Identity, Reputation, and Validation. The **Identity Registry** (ERC-721 based) mints a unique AgentID (an NFT) for each agent, with a `tokenURI` pointing to an off-chain registration file. This file contains the agent's basic info, service endpoints, and capabilities. A critical security feature is domain verification, requiring agents to host a signed file at a specific path on their domain to prove ownership and prevent spoofing. Key audit points include access controls for URI updates, use of immutable storage, proper cryptographic signature validation (EIP-712), and prevention of signature replay attacks. The **Reputation Registry** provides a standard interface for submitting and aggregating feedback. It uses a "Payment-Proof Linking" mechanism, where feedback submissions must include a proof of a payment (e.g., an x402 transaction hash), making Sybil attacks economically costly. Audit focuses include enforcing payment proof validity, constraining score ranges, and ensuring robust, manipulation-resistant off-chain aggregation algorithms. The **Validation Registry** allows agents to submit their work for independent verification, crucial for high-stakes tasks. It supports two models: 1. **Cryptoeconomic Validation:** Agents stake funds, which can be slashed via a fraud-proof ...

With the ERC-8004 (Trustless Agents) standard officially deployed on the Ethereum mainnet, AI Agent identity and reputation management have entered a new stage of verifiability and trustlessness. This standard provides agents with an on-chain verifiable "identity system" through three core registries: the Identity Registry, Reputation Registry, and Validation Registry. This article will adopt a security audit perspective, combining the technical details of ERC-8004, to analyze the key points of risk for each registry, providing a practical audit guide for developers and auditors.

Technical Details and Audit Key Points

The key to ERC-8004 lies in its three registries:

1. Identity Registry

A minimal on-chain handle based on ERC-721, with URIStorage extension, resolving to the agent's registration file, providing a portable, censorship-resistant identifier for each agent.

In the ERC-8004 architecture, the Identity Registry is built on ERC-721 and extends the URIStorage functionality. In other words, each agent corresponds to a unique NFT on the chain, this NFT is called an AgentID.

When a developer creates an agent, they call the register function of the registry contract, minting a new AgentID. This token is bound to a tokenURI, pointing to a JSON file stored off-chain—the so-called "agent registration file." The registration file must follow strict specifications, typically including three core types of content:

- Basic information, such as name, description, avatar URL;

- Service endpoints, which are the network addresses where the agent can be accessed, supporting various protocols like HTTP, WebSocket, Libp2p, A2A, MCP;

- Capability declarations, i.e., a list of tasks the agent can perform, such as image generation, arbitrage trading, or code auditing.

Self-declaration alone is clearly insufficient to establish trust, so ERC-8004 introduces a domain verification mechanism. The agent must host a signature file under its declared domain, at the path /.well-known/agent-card.json. The on-chain registry verifies this link, thereby binding the on-chain AgentID to the corresponding DNS domain. The significance of this step is to prevent phishing and impersonation attacks; an agent cannot arbitrarily claim to belong to a domain; it must prove control with a cryptographic signature.

Audit Key Points:

● Check the access control of the setTokenURI function, ensuring only the agent owner or an authorized role (e.g., onlyOwnerAfterMint) can update the URI.

● Review whether the URI supports immutable storage schemes (e.g., IPFS, Arweave). If centralized HTTP links are used, assess the security of domain control rights to prevent DNS hijacking.

● Verify the legality of the URI format to avoid contract exceptions caused by null pointers or invalid URIs.

● Verify that the contract strictly enforces cryptographic signature verification (e.g., EIP-712) when checking domain signatures, preventing signature forgery or replay attacks.

● Check the expiration mechanism for domain ownership proofs to prevent long-valid signatures from being reused.

● Ensure the domain resolution process does not rely on centralized oracles, avoiding single points of failure or manipulation.

2. Reputation Registry

A standard interface for publishing and obtaining feedback signals. Scoring and aggregation happen both on-chain (for composability) and off-chain (for complex algorithms), enabling an ecosystem of professional services like agent scoring, audit networks, and insurance pools.

Used for providing feedback and evaluation on registered AI Agents. Simple feedback submission occurs on-chain, with the potential for complex, aggregated off-chain processing before being recorded on-chain.

ERC-8004 also incorporates a "Payment-Proof Linking" mechanism to prevent malicious review spamming. When Agent A completes an evaluation of Agent B, it calls the giveFeedback function. This function not only accepts a score (0-100) and a comment hash but also allows for a paymentProof field, typically the hash of an x402 transaction. This makes the cost of spamming reviews extremely high, significantly reducing the possibility of Sybil attacks. Ultimately, the system naturally rewards agents with stable and high-quality performance.

Audit Key Points:

● Verify that the giveFeedback function mandates the paymentProof parameter and check if this parameter is a valid x402 transaction hash (or conforms to other payment standards). Ensure payment proofs cannot be reused (e.g., record used hashes) to prevent multiple reviews from a single payment.

● Check if the scoring range (0-100) is enforced at the contract level to avoid out-of-bounds scores disrupting aggregation logic.

● Evaluate the anti-manipulation properties of the off-chain aggregation algorithm: e.g., whether it uses medians, trims extreme values, or uses weighted averages, and whether it penalizes anomalous behavior (like a large number of reviews in a short time).

● Review slashing conditions for clarity and verifiability, e.g., whether they rely on on-chain evidence or fraud proofs submitted by third-party oracles.

● Ensure slashing logic does not contain centralized privileges (e.g., an admin can arbitrarily confiscate staked funds); slashing trigger conditions should be executed automatically solely by the smart contract.

● Test the lock-up period and conditions for staked fund withdrawal to prevent agents from urgently withdrawing funds just before facing slashing.

3. Validation Registry

A universal hook for requesting and recording checks by independent validators (e.g., zkML verifiers, TEE oracles, trusted judges).

Reputation reflects the past, but in high-risk scenarios (like large fund allocation), history alone is not enough. The Validation Registry allows agents to submit results for verification by third parties or automated systems, which can use methods like attested safe inference re-execution, zkML verifiers, or TEE oracles to verify or reject requests.

The first model is cryptoeconomic validation, based on game-theoretic security design. The agent must stake a certain amount of native token or stablecoin in the registry. If the agent fails to perform or provides incorrect results, the verifier network can submit a fraud proof, triggering the smart contract to automatically slash its staked funds. This model is suitable for tasks where results are easy to verify but the computation process is opaque, such as data scraping or simple API services.

The second model is cryptographic validation, based on mathematical security principles. TEE attestation (Trusted Execution Environment) allows the agent to run in a security-hardened hardware environment, such as Intel SGX or AWS Nitro. The Validation Registry can store and verify remote attestation reports from the hardware, proving that the agent is indeed running an untampered specific version of the code.

zkML (Zero-Knowledge Machine Learning) is another method of cryptographic validation. The agent submits a zero-knowledge proof along with the inference result. This proof can be verified at very low cost by an on-chain verification contract, mathematically guaranteeing that the output was indeed produced by a specific model (e.g., Llama-3-70B) on a specific input. This prevents "model swapping" attacks, where a service provider claims to use a high-end model but actually uses a lower-tier model to save costs.

Audit Key Points

For cryptoeconomic validation, check:

● Check the submission window for fraud proofs: Is enough time given for verifiers to discover and submit proofs? A window too short might miss malicious behavior, while too long locks funds for extended periods.

● Verify the adjudication logic for fraud proofs: Does it rely on a multi-signature verifier set? If so, review the decentralization level and threshold settings for verifier selection; if adjudication is fully on-chain, ensure the basis for judgment (e.g., on-chain verifiable results) exists and is unambiguous.

● Ensure the staked amount matches the risk, preventing low-cost malicious behavior (e.g., staking too little, where the profit from misbehavior far exceeds the loss).

For TEE attestation, check:

● Check if the contract verifies the timeliness of the TEE proof (e.g., includes a timestamp or block height) to prevent expired proofs from being accepted.

● Verify that the proof content includes the agent's code hash and input/output digests, ensuring the proof is bound to the specific task and avoiding cross-task reuse.

● Evaluate if the TEE proof verification logic relies on external oracles (e.g., Intel IAS). If it does, audit the oracle's security and decentralization level.

For zkML validation, check:

● Confirm the contract integrates an audited zk verification library (e.g., SnarkVerifier) and is correctly configured with verification keys for the specific proof system (e.g., Groth16, PLONK).

● Check if the verification contract restricts the models and input ranges applicable to the proof, preventing model swapping attacks (e.g., a proof generated for a small model is claimed to be from a large model).

● Evaluate the decentralization level of proof generation: Does it rely on a single prover? If multiple provers exist, a consensus mechanism is needed to prevent malicious provers.

Conclusion

ERC-8004 provides a standard for building trust in AI Agents, and its security is crucial for the entire on-chain Agent ecosystem. Security audit work requires a deep understanding of the design intent and potential risks of the three registries. Furthermore, the complexity of cross-contract interactions and common vulnerabilities cannot be ignored. Comprehensive and rigorous audits are necessary to ensure ERC-8004 truly delivers on its "trustless" promise, laying a secure foundation for the future of autonomous agents.

Related Questions

QWhat are the three core registries defined by the ERC-8004 standard, and what is the primary function of each?

AThe three core registries are: 1. Identity Registry: Provides a minimal on-chain handle based on ERC-721 with URIStorage extension, resolving to a proxy's registration file to offer a portable, censorship-resistant identifier. 2. Reputation Registry: A standard interface for publishing and obtaining feedback signals, enabling both on-chain and off-chain scoring and aggregation for an ecosystem of professional services like agent rating, audit networks, and insurance pools. 3. Validation Registry: A general-purpose hook for requesting and recording checks by independent validators (e.g., zkML verifiers, TEE oracles, trusted judges) to verify an agent's work output for high-stakes scenarios.

QWhat mechanism does ERC-8004 use to prevent Sybil attacks in its Reputation Registry, and what is a key audit point related to this?

AERC-8004 uses a 'Payment-Proof Linking' mechanism to prevent Sybil attacks. When an agent gives feedback, the `giveFeedback` function requires a `paymentProof` parameter, typically a hash of an x402 transaction, which makes the cost of spamming reviews extremely high. A key audit point is to verify that the function enforces this requirement and checks that the `paymentProof` is a valid, non-reusable transaction hash to prevent a single payment from being used for multiple reviews.

QIn the context of the Identity Registry, what is the purpose of the domain verification mechanism, and what is a critical security risk auditors must check for?

AThe domain verification mechanism binds an on-chain AgentID to a specific DNS domain by requiring the agent to host a signed file at `/.well-known/agent-card.json` on that domain. This prevents phishing and impersonation attacks by cryptographically proving control of the domain. A critical security risk for auditors to check is whether the URI in the token metadata uses a centralized HTTP link, which could be vulnerable to DNS hijacking, and to assess the security of domain control.

QWhat are the two main models of verification described for the Validation Registry, and what is a primary cryptographic concern for each?

AThe two main models are: 1. Cryptoeconomic Verification: Relies on staking and fraud proofs. A primary concern is ensuring the staking amount is sufficient to disincentivize malicious behavior, as a low stake could make the cost of cheating lower than the potential profit. 2. Cryptographic Verification: Includes TEE Attestation and zkML. For TEE, a key concern is verifying the timeliness and task-specific binding of the attestation proof to prevent replay attacks. For zkML, a primary concern is ensuring the verification contract is correctly configured with audited libraries and restricts the proof to the intended model and input to prevent model-swapping attacks.

QRegarding the Reputation Registry's on-chain aggregation, what is an important algorithmic consideration auditors must evaluate to ensure manipulation resistance?

AAuditors must evaluate the off-chain aggregation algorithm for its resistance to manipulation. This includes checking if it uses techniques like calculating the median, trimming extreme values, or applying weighted averages to mitigate the impact of outlier scores. They should also assess if the algorithm incorporates penalties for anomalous behavior, such as a high volume of reviews submitted in a very short period.

Related Reads

First Batch of Keynote Speakers and Partners Announced! Web2+3 Summit: Defining the Next Generation of Digital Economy

Web2+3 Summit: Defining the Next Generation of Digital Economy The 6th BEYOND International Technology Innovation Expo (BEYOND Expo 2026), Asia's largest tech and ecosystem exhibition, is launching a dedicated Web2+3 stage for the first time. Co-hosted by BEYOND Expo and ChainNeXT Group, the Web3 Summit will take place from May 28–30, 2026. Against the backdrop of accelerating global tech integration, the boundaries between Web2 and Web3 are rapidly blurring. With clearer global regulations for blockchain-driven internet (Web3) and the special issuance of a Hong Kong dollar stable币 license by the Hong Kong SAR government on April 10, 2026, Web3's decentralized principles are quickly merging with traditional industries (Web2) such as e-commerce, finance, and artificial intelligence. Focused on blockchain-driven digital economy elements, the summit will center on three core principles—implementability, commercial viability, and compliance. It will bring together top Web3 experts to discuss key integration areas like stablecoin payment finance (PayFi), real-world asset tokenization (RWA), and decentralized AI (DeAI), unveiling new opportunities for industrial innovation. The first wave of confirmed speakers includes Jack Kong (Director of Hong Kong Cyberport, Chairman of Nano Labs), Yat Siu (Chairman of Animoca Brands), Michael Wu (Co-founder & CEO of Amber Group), Michael Heinrich (Co-founder & CEO of 0G), and Art Abal (Co-founder of Vana). More Web3 ecosystem pioneers, AI, and fintech experts will be announced soon. Core forum topics include: - Web2+DeAI: New AI Paradigms Driven by Decentralized Infrastructure - Web2+RWA: Real-World Asset Tokenization and Global Liquidity - Web2+PayFi: Cross-Border Payments and Financial Innovation Powered by Crypto Infrastructure - Web2+3 AI: Autonomous Agents and the Crypto Economy - Web2+3 Wealth: On-Chain and Off-Chain Integrated Investment Ecosystems - Web2+3 Commerce: A New Landscape for Global Trade Driven by Stablecoins Additional agenda details will be released in the near future.

marsbit59m ago

First Batch of Keynote Speakers and Partners Announced! Web2+3 Summit: Defining the Next Generation of Digital Economy

marsbit59m ago

Trading

Spot
Futures

Hot Articles

Discussions

Welcome to the HTX Community. Here, you can stay informed about the latest platform developments and gain access to professional market insights. Users' opinions on the price of AI (AI) are presented below.

活动图片