Don't let malformed set_parameters requests crash the node (backport #3256) - #3264
Open
mergify[bot] wants to merge 2 commits into
Open
Don't let malformed set_parameters requests crash the node (backport #3256)#3264mergify[bot] wants to merge 2 commits into
mergify[bot] wants to merge 2 commits into
Conversation
The set_parameters and set_parameters_atomically service handlers only caught ParameterNotDeclaredException. A request carrying a parameter with an empty name (InvalidParametersException) or an unknown value type (UnknownTypeError, thrown by Parameter::from_parameter_msg) let the exception escape the service callback, unwind through the executor's spin(), and terminate the node -- an unauthenticated remote DoS on any node exposing the default parameter services. Broaden both handlers to catch std::exception and return an unsuccessful SetParametersResult instead. In the atomic handler, move the from_parameter_msg conversion inside the try so an unknown type raised during conversion is handled too. Adds regression tests covering empty name (typed client) and unknown type (raw client) for both services. Signed-off-by: Bas Zalmstra <4995967+baszalmstra@users.noreply.github.com> Signed-off-by: Alejandro Hernandez Cordero <ahcorde@gmail.com> Co-authored-by: Alejandro Hernandez Cordero <ahcorde@gmail.com> (cherry picked from commit 2e5a8b9) # Conflicts: # rclcpp/test/rclcpp/test_parameter_service.cpp
Contributor
Author
|
Cherry-pick of 2e5a8b9 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
Signed-off-by: Janosch Machowinski <jmachowinski@users.noreply.github.com>
Collaborator
|
Pulls: #3264 |
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.
The default parameter services crash the whole node on a malformed
set_parametersrequest. Both handlers only catchParameterNotDeclaredException, but an empty name (InvalidParametersException) or an unknown value type (UnknownTypeErrorfromfrom_parameter_msg) escapes the callback andspin(), taking the node down. With no access control by default, any peer on the graph can trigger it.Both handlers now catch
std::exceptionand return an unsuccessful result. I also moved thefrom_parameter_msgconversion in the atomic handler inside thetry, which the unknown-type case there wasn't covered by before.Testing
Added regression tests for both services (empty name via the typed client, unknown type via a raw client). I couldn't build Rolling locally, so I'd like CI to confirm; the crash itself reproduces with a single
ros2 service callto/<node>/set_parametersusing{name: ''}.This is an automatic backport of pull request #3256 done by [Mergify](https://mergify.com).