[Bug]: Agent card signature verification raises raw binascii.Error on a malformed protected header instead of SignatureVerificationError
メンテナーはふだん 2 日以内に返信
@rohityan がすでに取り組んでいます。
2026年10月9日 から。
評価
この issue はまだ評価されていません。
説明
What happened?
create_signature_verifier's verification loop (src/a2a/utils/signing.py:139-159) only catches PyJWTError:
for agent_card_signature in agent_card.signatures:
try:
protected_header_json = base64url_decode(
agent_card_signature.protected.encode('utf-8')
).decode('utf-8') # may raise binascii.Error / UnicodeDecodeError
protected_header = json.loads(protected_header_json) # may raise JSONDecodeError
...
verification_key = key_provider(kid, jku) # may raise anything (e.g. network errors)
jwt.decode(...)
break
except PyJWTError:
continue
agent_card_signature.protected is an attacker-controlled field. A malformed value makes base64url_decode raise a raw binascii.Error, which escapes the verifier entirely — violating the module's own contract: the canonicalization step just above explicitly converts failures to InvalidSignaturesError "so every failure on this path is a SignatureVerificationError", but the per-signature loop does not.
It also breaks the documented multi-signature semantic ("succeeds if at least one signature is valid"): a card holding [malformed_signature, valid_signature] raises instead of verifying.
Additionally, any exception raised by key_provider (e.g. a network failure while fetching the JKU) aborts the whole loop for the same reason.
Reproduction
from a2a.types.a2a_pb2 import AgentCard, AgentCardSignature
from a2a.utils.signing import (
SignatureVerificationError,
create_signature_verifier,
)
verifier = create_signature_verifier(
key_provider=lambda kid, jku: b'dummy-key',
algorithms=['RS256'],
)
card = AgentCard(
name='t',
version='1.0',
signatures=[
AgentCardSignature(protected='!!!not-base64url!!!', signature='aaa')
],
)
try:
verifier(card)
except SignatureVerificationError as e:
print(f'contract respected: {type(e).__name__}: {e}')
except Exception as e:
print(f'CONTRACT BROKEN -> {type(e).__name__}: {e}')
Observed output:
CONTRACT BROKEN -> Error: Invalid base64-encoded string: number of data characters (13) cannot be 1 more than a multiple of 4
Expected behavior
Every failure on the verification path should surface as SignatureVerificationError (per the contract established at signing.py:124-128), and a malformed signature should count as "invalid" so remaining signatures are still attempted.
Suggested fix
Widen the per-signature except clause, e.g.:
except (PyJWTError, ValueError, binascii.Error, UnicodeDecodeError):
continue
or wrap the loop body so parse/key-provider failures are logged and treated as an invalid signature. This is non-breaking for correct inputs and only converts escapes into the documented error type.
Happy to submit a PR with tests.
Code of Conduct
- I agree to follow this project's Code of Conduct
- 主要言語
- Python
- スター
- 2.2k
- フォーク
- 509
- 平均マージ
- 3日 11時間
- マージ済み PR(30日)
- 43
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
a2aproject/a2a-python のほかの issue
-
[Bug]: REST task/request id sanitization対応中かも @Linux2010 が 105 日前に担当しました。 オープンmaintainers-only
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
a2aproject/a2a-python#805 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
[Bug]: Framework-written FAILED status drops status.timestamp, persisting last_updated as NULL対応中かも @rohityan が 2 日前に担当しました。 オープン
a2aproject/a2a-python#1331 · 担当者 2 名 ·
メンテナーはふだん 2 日以内に返信
-
[Bug]: message/send hangs forever when the AgentExecutor returns without producing events対応中かも @rohityan が 2 日前に担当しました。 オープン
a2aproject/a2a-python#1330 · 担当者 2 名 ·
メンテナーはふだん 2 日以内に返信
-
Whole numbers in a data Part are returned as floats (e.g. 4326 becomes 4326.0)対応中かも @rohityan が 2 日前に担当しました。 オープン
a2aproject/a2a-python#1328 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
[Feat]: Cluster mode: detect and recover tasks abandoned by a crashed replica (heartbeat/lease)対応中かも @ishymko が 2 日前に担当しました。 オープンcomponent: server status: needs review
a2aproject/a2a-python#1324 · コメント 4 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
a2aproject/a2a-python の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
GAM-team/got-your-back#547 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
UKGovernmentBEIS/inspect_ai#5821 ·
メンテナーはふだん 1 日以内に返信
-
docs help wanted
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
-
evidence wanted good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
open-coder-ai/agentseam#195 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信