-
Notifications
You must be signed in to change notification settings - Fork 132
fix(rest): map invalid history length to InvalidParamsError #715
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c41100d
758f24e
3ac5f90
ad84170
4d7cb1d
91fd77d
c2bbaab
c330b8c
105345a
a32ae7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -415,7 +415,12 @@ public HTTPRestResponse subscribeToTask(ServerCallContext context, String tenant | |
| */ | ||
| public HTTPRestResponse getTask(ServerCallContext context, String tenant, String taskId, @Nullable Integer historyLength) { | ||
| try { | ||
| TaskQueryParams params = new TaskQueryParams(taskId, historyLength, tenant); | ||
| TaskQueryParams params; | ||
| try { | ||
| params = new TaskQueryParams(taskId, historyLength, tenant); | ||
| } catch (IllegalArgumentException e) { | ||
| throw new InvalidParamsError(e.getMessage()); | ||
| } | ||
|
Comment on lines
+419
to
+423
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this correctly handles the exception, using a nested |
||
| Task task = requestHandler.onGetTask(params, context); | ||
| if (task != null) { | ||
| return createSuccessResponse(200, io.a2a.grpc.Task.newBuilder(ProtoUtils.ToProto.task(task))); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling logic introduced here uses
InvalidParamsError, which is eventually serialized into a JSON response via theHTTPRestErrorResponse.toJson()method (line 950). This method is vulnerable to JSON injection because it manually constructs a JSON string by concatenating the error message without proper escaping. If an error message contains double quotes, newlines, or other special characters, it will result in malformed JSON or allow an attacker to inject additional fields into the response. It is recommended to use a proper JSON serialization library (like the one already used increateSuccessResponse) to generate the error response.