Skip to content

feat: verify signed peer AgentCards (WP13) - #123

Merged
pavelanni merged 3 commits into
mainfrom
feature/signed-cards
Nov 7, 2026
Merged

pavelanni merged 3 commits into
mainfrom
feature/signed-cards

Conversation

@pavelanni

Copy link
Copy Markdown
Collaborator

Summary

  • Optional per-peer card_public_key (PEM path). Before the first a2a_call, fetch <peer origin>/.well-known/agent-card.json and verify its JWS.
  • The card file is the JWS itself (payload = AgentCard JSON), matching what SignedCardHandler serves verbatim. ES256 (P-256) and RS256 only; none/HS* are refused.
  • Successful verification is cached per peer per process; failures are retried on the next call.
  • Cross-host redirects are rejected; the card body is capped at 1 MiB.
  • Failure surfaces as peer <name>: agent card signature invalid.

Files

  • internal/a2acall/cardverify.go (+ tests)
  • internal/a2acall/a2acall.go
  • internal/cmd/agentconfig.go (+ tests)
  • internal/cmd/runtime.go — one line to pass the parsed key; outside WP13's file list but required to wire config to the tool.

Test plan

  • TestVerifyCard table: valid, tampered, wrong key, unsigned, nil key.
  • Cross-host redirect rejection.
  • Success cached; failure retried.
  • LoadCardPublicKey and config-level relative path resolution.
  • make fmt lint test and go test ./... green.

🤖 Generated with Claude Code

Verify a peer's well-known agent card JWS against an optional
card_public_key before the first a2a_call. Successful verification is
cached per peer for the process; failures are retried on the next call.
Redirects to a different host are rejected.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

The well-known card file is an AgentCard carrying a signatures array of
detached JWS entries, not a JWS envelope. Verify any one signature over
the RFC 8785 canonical form of the card with signatures removed, bind
ES256/RS256 to the configured key type, and classify format, signature,
and fetch failures separately. Concurrent first calls for one peer now
share a single card fetch.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
A signer may strip default-valued properties before signing while a
struct-based server re-emits them. Verify against several canonical
candidates: as served, empty collections removed, all defaults removed,
and empty required properties removed. Require typ=JOSE and a non-empty
kid in the protected header, detach the shared first-call fetch from the
leader's cancellation, and document the wire format and normalization.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Pavel Anni <[email protected]>
@pavelanni
pavelanni marked this pull request as ready for review November 7, 2026 01:06
@pavelanni
pavelanni merged commit db32804 into main Nov 7, 2026
5 checks passed
@pavelanni
pavelanni deleted the feature/signed-cards branch November 7, 2026 01:06
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.

1 participant