From 08de93db183bf9f596e19073b906a1afae602af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Ma=C5=9Blanka?= Date: Fri, 9 Aug 2024 09:56:00 +0000 Subject: [PATCH] c/health: added validation of received health report node_id MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added validation of the node_id of the reply received from the node. The report is not considered as valid if the reply node id doesn't match the id of node the report was sent to. Signed-off-by: Michał Maślanka --- src/v/cluster/health_monitor_backend.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/v/cluster/health_monitor_backend.cc b/src/v/cluster/health_monitor_backend.cc index 90aace877444..ac0a47dddf38 100644 --- a/src/v/cluster/health_monitor_backend.cc +++ b/src/v/cluster/health_monitor_backend.cc @@ -370,20 +370,23 @@ health_monitor_backend::collect_remote_node_health(model::node_id id) { }); } -result -map_reply_result(result reply) { +result map_reply_result( + model::node_id target_node_id, result reply) { if (!reply) { return {reply.error()}; } if (!reply.value().report.has_value()) { return {reply.value().error}; } + if (reply.value().report->id != target_node_id) { + return {errc::invalid_target_node_id}; + } return {std::move(*reply.value().report).to_in_memory()}; } result health_monitor_backend::process_node_reply( model::node_id id, result reply) { - auto res = map_reply_result(std::move(reply)); + auto res = map_reply_result(id, std::move(reply)); auto [status_it, _] = _status.try_emplace(id); if (!res) { vlog(