Skip to main content
Back to all articles
AI Engineering 9 min readUpdated September 15, 2026

A2A Agent Cards Are Input, Not Identity: Designing a Verification Boundary

Agent Cards make A2A discovery easy, but discovery metadata is not proof of identity. Build a production-grade trust boundary that verifies signatures, constrains endpoints, applies local policy, and makes unverified agent calls difficult to express in TypeScript.

By Salman Butt · Senior Full-Stack & Generative AI Engineer
#A2A Protocol#AI Agents#Security#TypeScript#Agentic AI#Distributed Systems
On this page

A2A Agent Cards Are Input, Not Identity: Designing a Verification Boundary

Agent-to-agent communication changes an important assumption in an AI system: the next component your agent talks to may be owned, deployed, and changed by someone else.

With A2A, discovery is intentionally convenient. A client can fetch an Agent Card, inspect the remote agent's capabilities, learn which interfaces it supports, understand its authentication requirements, and decide whether the agent appears useful for a task.

That convenience creates a security boundary.

An Agent Card is discovery metadata. It is not, by itself, proof that the publisher is trusted, that every advertised endpoint is safe to call, or that your application should satisfy every authentication requirement it declares.

A useful production rule is:

Parse first. Verify second. Apply policy third. Only then allow the card to influence network or credential decisions.

In this article, I will build that rule into the architecture so an unverified Agent Card cannot casually flow into the code that performs an outbound A2A call.

What an Agent Card gives you

In A2A v1.0, an Agent Card describes an agent and how clients can interact with it. Among other fields, it can contain:

  • the agent's name and provider metadata;
  • supported interfaces and their URLs;
  • protocol binding and protocol version information;
  • capabilities and skills;
  • security schemes and security requirements;
  • optional JSON Web Signatures for the card.

The standard discovery location is commonly /.well-known/agent-card.json.

This is exactly the information a client needs for interoperability. It is also information that can affect security-sensitive decisions.

Imagine a purchasing agent discovers a supplier agent. The returned card says:

  • "I support the skill you need";
  • "send requests to this URL";
  • "authenticate using this scheme".

If application code trusts those claims immediately, the remote document has started controlling where your server connects and potentially where credentials are sent.

That is why schema-valid and trusted must be separate states.

The trust states should be explicit

I like to model Agent Card handling as a small state machine:

Text
remote bytes   |   vparsed card   |   vschema-valid card   |   vsignature / provenance verified   |   vlocal policy accepted   |   vtrusted card -> A2A client construction

Each transition answers a different question.

Parsing asks: is this valid JSON?

Schema validation asks: does it have the structure A2A expects?

Signature verification asks: does a trusted verification path establish integrity/provenance for this card?

Policy evaluation asks: even if authentic, are we willing to communicate with this agent under these conditions?

Combining these into a single vague isValid boolean loses information and makes security reviews harder.

Make invalid trust flows harder to write in TypeScript

TypeScript can make the boundary visible to the rest of the application.

TypeScript
declare const verifiedAgentCard: unique symbol;​type AgentInterface = {  url: string;  protocolBinding: string;  protocolVersion: string;};​type AgentCard = {  name: string;  version: string;  supportedInterfaces: AgentInterface[];  securitySchemes?: Record<string, unknown>;  securityRequirements?: Array<Record<string, string[]>>;  signatures?: Array<{    protected: string;    signature: string;    header?: Record<string, unknown>;  }>;};​type UntrustedAgentCard = AgentCard;​type TrustedAgentCard = AgentCard & {  readonly [verifiedAgentCard]: true;};

The brand is intentionally not exported from the verification module. Other modules can receive a TrustedAgentCard, but they cannot legitimately create one themselves.

This does not replace runtime security. TypeScript disappears at runtime. Its value is architectural: code review and autocomplete now reinforce the same boundary that runtime checks enforce.

For example:

TypeScript
export function createRemoteAgentClient(card: TrustedAgentCard) {  const primary = card.supportedInterfaces[0];​  if (!primary) {    throw new Error("Verified card has no supported interface");  }​  return new RemoteAgentClient({    endpoint: primary.url,    protocolBinding: primary.protocolBinding,    protocolVersion: primary.protocolVersion,  });}

A raw card fetched from the network cannot be passed directly to this function without deliberately bypassing the type system.

One function should own the admission boundary

Instead of fetching Agent Cards throughout the codebase, funnel discovery through one admission function.

TypeScript
type VerificationContext = {  expectedAgentId: string;  allowedHosts: Set<string>;  allowedAlgorithms: Set<string>;};​export async function loadTrustedAgentCard(  discoveryUrl: URL,  context: VerificationContext,): Promise<TrustedAgentCard> {  assertSafeDiscoveryUrl(discoveryUrl);​  const raw = await fetchAgentCard(discoveryUrl);  const card = parseAndValidateAgentCard(raw);​  await verifyAgentCardSignatures(card, {    expectedAgentId: context.expectedAgentId,    allowedAlgorithms: context.allowedAlgorithms,  });​  assertInterfacesAllowed(card, context.allowedHosts);  assertSecurityPolicy(card);​  return card as TrustedAgentCard;}

The cast happens once, after all runtime checks succeed. That line is the trust transition and deserves the same scrutiny as an authentication middleware or authorization gate.

Everything before it handles hostile input. Everything after it may rely on the guarantees documented by this boundary.

Signature verification proves integrity, not permission

A2A v1.0 supports Agent Card signatures using JSON Web Signature (JWS). The specification defines a canonicalization process based on RFC 8785 and excludes the signatures field from the signed payload.

That gives clients a standard way to verify that the relevant card content matches what was signed.

But cryptographic verification still requires a trust decision about the key.

If an attacker can provide both the malicious card and the verification key you blindly trust, the signature only proves that the attacker signed their own data.

A verifier therefore needs a key-resolution policy appropriate to the deployment. Depending on your environment, that might mean:

  • an enterprise trust registry;
  • keys exchanged during partner onboarding;
  • a validated JWKS source anchored to an independently trusted identity;
  • a certificate or organizational PKI;
  • another explicit trust store.

The important separation is:

Text
signature is mathematically valid            !=signer is trusted for this agent identity            !=this card is acceptable under my policy

A production verifier should also allowlist accepted signing algorithms. This reduces algorithm-confusion and downgrade mistakes.

Pseudo-code for the adapter might look like this:

TypeScript
async function verifyAgentCardSignatures(  card: AgentCard,  options: {    expectedAgentId: string;    allowedAlgorithms: Set<string>;  },): Promise<void> {  if (!card.signatures?.length) {    throw new Error("Agent Card is unsigned");  }​  const result = await signatureVerifier.verify(card, {    resolveKey: (kid, jku) =>      trustedKeyResolver.resolve({        expectedAgentId: options.expectedAgentId,        kid,        jku,      }),    allowedAlgorithms: options.allowedAlgorithms,  });​  if (!result.ok) {    throw new Error("No trusted Agent Card signature verified");  }}

I would prefer a well-tested A2A/JOSE implementation over reimplementing JWS and canonicalization by hand. The boundary above is where that verifier belongs.

A valid signature does not make an endpoint safe

Suppose a trusted partner signs a card that points to a new endpoint. The signature verifies perfectly.

Should your infrastructure immediately connect to it?

Not necessarily.

Authentication answers who signed something. Authorization and policy answer what that identity is allowed to make your system do.

This matters because Agent Card interface URLs participate in outbound network behavior. If your server can be influenced into connecting to arbitrary destinations, you have the ingredients for server-side request forgery (SSRF).

At the application layer, I would at least enforce HTTPS and an expected host policy:

TypeScript
function assertInterfacesAllowed(  card: AgentCard,  allowedHosts: Set<string>,): void {  if (card.supportedInterfaces.length === 0) {    throw new Error("Agent Card exposes no interfaces");  }​  for (const item of card.supportedInterfaces) {    const url = new URL(item.url);​    if (url.protocol !== "https:") {      throw new Error(`Non-HTTPS A2A interface rejected: ${url.protocol}`);    }​    if (!allowedHosts.has(url.hostname)) {      throw new Error(`A2A host is outside policy: ${url.hostname}`);    }  }}

For internet-facing production systems, host string checks alone are not enough. Your egress design should also account for:

  • loopback addresses;
  • RFC1918/private network ranges;
  • link-local destinations;
  • cloud instance metadata endpoints;
  • IPv6 private/link-local ranges;
  • DNS rebinding;
  • redirects to a destination that was never approved.

The strongest control is often outside the application: an egress proxy, firewall, service mesh policy, or tightly scoped network allowlist. Application checks then become defense in depth instead of the only line of protection.

Treat authentication declarations as claims, not commands

An Agent Card can describe security schemes and security requirements. That is useful negotiation metadata. It should not mean:

The remote card requested a credential, therefore send whatever credential makes the request succeed.

Your application must map the remote requirement to your own credential policy.

A useful interface is:

TypeScript
type CredentialDecision = {  schemeName: string;  audience: string;  scopes: string[];};​function chooseCredential(  card: TrustedAgentCard,  policy: LocalAgentPolicy,): CredentialDecision {  // Intersect what the agent supports with what we permit.  // Never forward ambient credentials simply because a card requests them.  return policy.selectCredentialFor(card);}

The key word is intersect.

The remote agent advertises what it supports. Your system decides what it is willing to use.

For OAuth-based deployments, prefer narrowly scoped, short-lived, audience-bound credentials when your identity platform supports them. Avoid forwarding a broad service or user token to another organization simply because it works.

The Agent Card describes the door. Your security policy decides which key, if any, may be used to open it.

Card changes need a lifecycle policy

Agent Cards are configuration, and configuration changes.

Providers may rotate keys, add capabilities, change endpoints, update security requirements, or publish a new protocol version. A secure design cannot assume that a card verified during onboarding remains correct forever.

There are several reasonable strategies, depending on risk:

1. Re-verify on every fetch

Simple and strong, but it may add latency and key-resolution traffic.

2. Cache by content hash

Verify once for a particular canonical card payload, then cache the verification result for a bounded TTL and trust context.

The cache key should include more than the URL. Consider:

Text
SHA-256(canonical card)+ trust-policy version+ verifier/key-set version

A policy update should invalidate old trust decisions even if the document has not changed.

3. Require approval for sensitive drift

For high-value integrations, you may allow routine changes while requiring review for events such as:

  • a new endpoint hostname;
  • a weaker authentication mechanism;
  • a new signing identity;
  • a protocol downgrade;
  • an unexpected capability or required extension.

The important point is that successful signature verification does not automatically approve configuration drift.

The fetch itself needs guardrails

The verification boundary starts before JSON parsing.

Remote discovery is an outbound HTTP operation, so make it intentionally boring:

TypeScript
async function fetchAgentCard(url: URL): Promise<unknown> {  const controller = new AbortController();  const timeout = setTimeout(() => controller.abort(), 4_000);​  try {    const response = await fetch(url, {      signal: controller.signal,      redirect: "manual",      headers: {        accept: "application/json",      },    });​    if (!response.ok) {      throw new Error(`Agent Card fetch failed: ${response.status}`);    }​    const contentLength = Number(response.headers.get("content-length") ?? 0);​    if (contentLength > 256_000) {      throw new Error("Agent Card exceeds size limit");    }​    return await response.json();  } finally {    clearTimeout(timeout);  }}

In a hardened implementation, enforce the maximum body size while streaming as well; Content-Length may be missing or dishonest.

I also prefer handling redirects explicitly. A discovery URL approved for partner.example should not silently redirect the server to an internal address or unrelated host.

Observability belongs inside the trust boundary

Security failures that disappear into a generic A2A request failed message are painful to investigate.

Record structured admission events such as:

TypeScript
interface AgentAdmissionEvent {  source: string;  agentName?: string;  cardHash?: string;  signerKeyId?: string;  decision: "accepted" | "rejected";  reason?: string;  policyVersion: string;}

Useful rejection reasons include:

  • malformed card;
  • unsupported protocol version;
  • missing signature;
  • untrusted signing key;
  • disallowed algorithm;
  • signature verification failure;
  • endpoint outside allowlist;
  • insecure endpoint scheme;
  • authentication policy mismatch;
  • required extension not supported.

Do not put access tokens, API keys, or other secrets into these logs.

A content hash is especially useful because it lets you correlate events involving the same card without storing the complete remote document in every log entry.

Responses from a trusted agent are still untrusted data

There is one more boundary that is easy to miss.

Verifying the Agent Card tells you something about the identity/integrity of the discovered configuration. It does not prove that the agent's future output is correct, safe, grounded, or authorized for your business workflow.

A trusted vendor's agent can still:

  • hallucinate;
  • return stale data;
  • produce malformed structured output;
  • be compromised after onboarding;
  • send instructions that should never automatically trigger a destructive action.

Agent identity and output safety are separate problems.

A robust system therefore has two independent gates:

Text
remote agent configuration        |        videntity + policy admission        |        vA2A interaction        |        vresponse validation + business authorization

The first gate protects who and where you communicate with. The second protects what your system is allowed to do with the result.

A production checklist

Before allowing a newly discovered A2A agent into an automated workflow, I would review these questions:

  • Is the Agent Card schema-valid?
  • Is a required signature present for this trust tier?
  • Was the signature verified using an independently trusted key-resolution path?
  • Are only explicitly accepted signing algorithms allowed?
  • Does the verified identity match the partner/agent we expected?
  • Are all advertised interface URLs compatible with our egress policy?
  • Are redirects controlled?
  • Are private, loopback, link-local, and metadata destinations blocked?
  • Do the advertised protocol versions and bindings match what we support?
  • Do authentication requirements intersect with our local credential policy?
  • Are credentials short-lived and minimally scoped where possible?
  • Are sensitive card changes detected and reviewed?
  • Is the verification decision cached only for an appropriate TTL?
  • Can we revoke trust quickly if a partner key or agent is compromised?
  • Are admission decisions observable without leaking secrets?
  • Are agent responses independently validated before business side effects?

If those questions do not have clear owners, the problem is not an A2A SDK problem. It is a trust-boundary design problem.

The architecture I would ship

The final shape is deliberately small:

Text
                 +----------------------+Internet ------> | Agent Card Fetcher   |                 | timeout / size / SSRF|                 +----------+-----------+                            |                            v                 +----------------------+                 | Schema Validation    |                 +----------+-----------+                            |                            v                 +----------------------+                 | Signature Verifier   |                 | trusted key resolver |                 +----------+-----------+                            |                            v                 +----------------------+                 | Local Policy Engine  |                 | endpoints / auth /   |                 | versions / drift     |                 +----------+-----------+                            |                            v                    TrustedAgentCard                            |                            v                 +----------------------+                 | A2A Client Factory   |                 +----------------------+

The important feature is not any individual check. It is that there is one path from remote discovery to outbound A2A communication, and that path changes the card's trust state only after verification and policy checks succeed.

That is much safer than relying on every engineer to remember, every time, that a JSON document called an "Agent Card" is still network input.

Final takeaway

A2A makes agent interoperability easier, but interoperability should not collapse the boundary between discovered and trusted.

Agent Cards are valuable because they are machine-readable contracts for discovery and interaction. Treat them exactly as you would any other remote security-sensitive configuration: validate structure, verify provenance, enforce your own policy, constrain network behavior, scope credentials, and observe every trust decision.

Then encode that decision into the software architecture.

When only a TrustedAgentCard can create an outbound client, verification stops being a guideline hidden in documentation and becomes a property of the codebase.

That is the kind of boundary I want around autonomous systems: not "developers should remember to check," but unsafe flows are difficult to express by accident.

References

KEEP READING

Related engineering notes