Skip to content

fix: Port A2A agent card RPC target origin validation to v1 - #6800

Merged
GWeale merged 1 commit into
v1from
backport-v1-pr11
Aug 19, 2026
Merged

fix: Port A2A agent card RPC target origin validation to v1#6800
GWeale merged 1 commit into
v1from
backport-v1-pr11

Conversation

@GWeale

@GWeale GWeale commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Ports fix: constrain the RPC targets of a network-fetched A2A agent card (upstream 16cbb7d1) to the v1 branch.

  • When agent_card is an http:// or https:// URL, every endpoint the card advertises (top-level url and each additional_interfaces[i].url) must match the source URL's origin — scheme, host and port — or RemoteA2aAgent raises AgentCardResolutionError.
  • Cleartext http:// is accepted only on a loopback host: localhost, a *.localhost name, or a loopback literal.
  • The origin comes from the configured URL, so a card served after a cross-origin redirect is rejected.

A deployment whose card host differs from its RPC host passes an AgentCard object to the constructor, or points agent_card at a local file path; both skip the check. No new public symbol, no opt-out flag.

Endpoint enumeration is re-implemented as a private _agent_card_rpc_urls in remote_a2a_agent.py rather than ported from upstream's a2a/_compat.py.

Before this change, `RemoteA2aAgent` accepted whatever RPC URL an agent card
advertised. Validation only checked that the card's `url` was non-empty and
parsed into a scheme and a netloc, so a card fetched over the network could
point the conversation, and any auth the client attaches to it, at any host,
over cleartext if it liked. Endpoints beyond the top-level `url` were not
looked at at all, even though the client factory negotiates its transport
across the card's whole interface list and can pick one of them.

Now, when the card was fetched over http or https, every URL it advertises
must use https and match the origin the card came from, comparing scheme,
host and port. Plain http stays allowed on a loopback host, which is the
shape the A2A local-development helpers emit. A card supplied as an
`AgentCard` object or read from a local file is left alone, since it did not
come off the network.

Behaviour change: a deployment that serves its agent card from one host and
its RPC endpoint from another now raises `AgentCardResolutionError` instead
of connecting, and so does one that advertises a cleartext endpoint off
loopback. A differing port counts as a differing origin. Because the origin
is compared against the URL that was configured rather than the one that
finally answered, a card reached through a redirect to another origin is
rejected as well. Passing the `AgentCard` object directly or pointing
`agent_card` at a local file remains available for those cases.

The upstream change routes endpoint enumeration through a compatibility
module that straddles `a2a-sdk` 0.3.x and 1.x. This branch pins
`a2a-sdk>=0.3.4,<0.4`, so the 0.3.x behaviour is implemented directly as a
private helper in `remote_a2a_agent.py` instead.
@GWeale GWeale changed the title fix: Port A2A agent card RPC target validation to v1 fix: Port A2A agent card RPC target origin validation to v1 Aug 19, 2026
@GWeale
GWeale merged commit ccb4812 into v1 Aug 19, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants