fix(builtin/a2a): restore OFFSEC-003 sanitize_a2a_result wrapping (mc#787) #814

Closed
fullstack-engineer wants to merge 1 commits from fix/offsec-003-builtin-a2a-sanitize into staging

1 Commits

Author SHA1 Message Date
e63bd7beca fix(builtin/a2a): restore OFFSEC-003 sanitize_a2a_result wrapping (mc#787)
All checks were successful
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 15s
sop-tier-check / tier-check (pull_request) Successful in 19s
audit-force-merge / audit (pull_request) Has been skipped
builtin_tools/a2a_tools.py:delegate_task() had sanitize_a2a_result wrapping
removed from all peer-sourced return paths. A malicious peer could inject
control markers (A2A_RESULT_FROM_PEER, SYSTEM, OVERRIDE, etc.) that the LLM
would interpret as trust-boundary instructions rather than peer content text.

Fix:
- Re-add `from _sanitize_a2a import sanitize_a2a_result` import
- Wrap all peer-controlled returns with sanitize_a2a_result():
  - parts[0].text (primary result)
  - str(result) for empty-parts case
  - str(result) for non-string result fallback
  - f"Error: {msg}" for peer error responses
  - str(data) for unknown-response-shape fallback
- Remove dead code (duplicate error-handling block after return statement)

Also removes duplicate test declarations blocking go build (TestHasUnresolvedVarRef_*
from org_test.go, TestExtractResponseText_ResultNotMap from delegation_test.go).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-13 08:16:05 +00:00