fix: sanitize internal exception messages in client-visible errors - #637
Open
ez-lbz wants to merge 2 commits into
Open
fix: sanitize internal exception messages in client-visible errors#637ez-lbz wants to merge 2 commits into
ez-lbz wants to merge 2 commits into
Conversation
🧪 Code Coverage
Generated by coverage-comment.yml |
Member
ez-lbz
force-pushed
the
fix/error-message-sanitization
branch
from
August 25, 2026 14:37
50f3c2f to
d2dfbf4
Compare
Contributor
Author
|
Hi @JakubWorek, thanks for the review note. I've updated the branch:
All CI checks (test, test-edge, coverage, eslint, integration, ITK, tck-test, approvals, Validate PR Title) are green on the new head. Thanks again! |
ez-lbz
force-pushed
the
fix/error-message-sanitization
branch
from
August 25, 2026 15:56
78ed3b5 to
d2dfbf4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
1. Sanitize internal exception messages before they reach clients (CWE-209)
Problem: Raw
Errormessages — which can contain stack traces, file paths, and library names — were propagated verbatim to client-visible error responses in four places: the REST error body, the JSON-RPC error envelope, the gRPC error details, and theFAILEDtask message synthesized when an agent executor throws. This leaks server internals (fingerprinting / information disclosure). All SDKs shared the gap.Fix (src/errors/base.ts):
clientSafeErrorMessage(error): semanticA2AErrormessages are deliberate protocol text and are kept; unknown/internal errors are replaced with'An unexpected error occurred.', with the internal detail logged server-side viaconsole.errorso diagnostics are not lost.Fix (src/errors/index.ts):
clientSafeErrorMessagefor consumers.Fix (src/errors/rest.ts):
toRestErrorBodyusesclientSafeErrorMessage(semantic messages and error-code semantics preserved).Fix (src/errors/json_rpc.ts):
toJsonRpcErrorusesclientSafeErrorMessagefor non-A2A errors, keeping theINTERNAL_ERROR(-32603) code.Fix (src/server/grpc/grpc_service.ts):
mapToErrorusesclientSafeErrorMessagefor non-A2A errors, keepingUNKNOWNstatus.Fix (src/server/request_handler/default_request_handler.ts):
FAILEDtask message synthesized by_runExecutor,_runStreamExecutor, and_handleProcessingErrornow usesAgent execution failed./Event processing loop failed.for raw errors (the detail is already logged right above each site); semanticA2AErrormessages keep theAgent execution error: <msg>/Event processing loop failed: <msg>form.Testing
npm test— 68 test files, 1511 tests passed.npx tsc --noEmit(no errors insrc/) andnpx tsc --noEmit -p tsconfig.test.jsonpass.toRestErrorBody/toJsonRpcErrorreplace rawErrormessages with the generic string while preserving codes, and keep semanticA2AErrormessages; gRPCmapToErrorreturns genericdetailsfor raw errors.default_request_handler.spec.ts(blocking/non-blocking executor failures, event-loop failure),streaming_errors.spec.ts(×2),auth_required.spec.ts,error_envelope.spec.ts, andexpress_app.spec.ts(JSON-RPC fallback error handling) now assert the sanitized generic message.Behavior change: internal exception messages are no longer sent to clients on any transport or in synthesized
FAILEDtask messages; semantic A2A error messages and codes are unchanged.