Skip to content

Don't let malformed set_parameters requests crash the node (backport #3256) - #3267

Open
mergify[bot] wants to merge 2 commits into
humblefrom
mergify/bp/humble/pr-3256
Open

Don't let malformed set_parameters requests crash the node (backport #3256)#3267
mergify[bot] wants to merge 2 commits into
humblefrom
mergify/bp/humble/pr-3256

Conversation

@mergify

@mergify mergify Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

The default parameter services crash the whole node on a malformed set_parameters request. Both handlers only catch ParameterNotDeclaredException, but an empty name (InvalidParametersException) or an unknown value type (UnknownTypeError from from_parameter_msg) escapes the callback and spin(), taking the node down. With no access control by default, any peer on the graph can trigger it.

Both handlers now catch std::exception and return an unsuccessful result. I also moved the from_parameter_msg conversion in the atomic handler inside the try, 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 call to /<node>/set_parameters using {name: ''}.


This is an automatic backport of pull request #3256 done by [Mergify](https://mergify.com).

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
@mergify mergify Bot added the conflicts label Sep 10, 2026
@mergify

mergify Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 2e5a8b9 has failed:

On branch mergify/bp/humble/pr-3256
Your branch is up to date with 'origin/humble'.

You are currently cherry-picking commit 2e5a8b9.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   rclcpp/src/rclcpp/parameter_service.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   rclcpp/test/rclcpp/test_parameter_service.cpp

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>
@jmachowinski

Copy link
Copy Markdown
Collaborator

Pulls: #3267
Gist: https://gist.githubusercontent.com/jmachowinski/2b6d1b7da7add2a1a8ba715541944ddd/raw/b72518ff1879cd09e117dbe73e4621aed68fa031/ros2.repos
BUILD args:
TEST args:
ROS Distro: humble
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20420

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants