a2aproject / a2aproject/a2a-js

[Bug]: Client caches an extended Agent Card before signature verification succeeds

Aperta
#705 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
613
Fork
169
Merge medio
1g 6h
PR unite (30g)
21

Descrizione

## What happened

When `Client.getAgentCard` fetches an authenticated extended Agent Card with a signature verifier, the client replaces its cached Agent Card before verification completes. If the verifier rejects the card, the call throws, but the unverified card remains active inside the client.

This can change later capability decisions. For example, an unverified extended card can set `pushNotifications: true` and `extendedAgentCard: false`; after the verification error is caught, a later `getAgentCard()` returns that unverified card without fetching or verifying again.

## What I expected

A fetched Agent Card should replace the client's cached card only after the supplied signature verifier succeeds. If verification fails, the previously trusted/public card should remain active, so subsequent calls can retry and capability checks cannot be influenced by rejected content.

## Steps to reproduce

1. Create a `Client` with a public Agent Card that has `extendedAgentCard: true` and `pushNotifications: false`.
2. Configure its transport to return an extended Agent Card named `"UNVERIFIED"` with `extendedAgentCard: false` and `pushNotifications: true`.
3. Call `getAgentCard` with a verifier that throws `Error("invalid signature")`, and catch the error.
4. Call `getAgentCard()` again without a verifier.
5. Observe that the transport was called only once and the second call returns `"UNVERIFIED"` with `pushNotifications: true`, even though that card failed verification.

## Additional context

A2A section 8.4.3 says clients should verify at least one signature before trusting an Agent Card. Section 13.3 recommends replacing the cached public card with the extended version, but the replacement should happen only after successful verification.

Suggested behavior: fetch into a temporary value, run the supplied verifier, then commit it to the client's cached Agent Card. On verification failure, retain the previous card.

Spec: https://github.com/a2aproject/A2A/blob/main/docs/specification.md#843-signature-verification

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Look at the `Client.getAgentCard` method and the caching logic. The bug is about the order of caching and verification. Start by finding where the fetched card is stored and where the signature verifier is called. The fix is to store the new card only after verification succeeds. Check the test steps in the issue to understand the expected flow.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, typescript
Ambito
backend-api-design, security
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Specificata chiaramente
Idoneità per principianti
65/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.