From d5697604d0fc55eed332c84d69a9d7da178bac0c Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Fri, 13 Oct 2023 17:57:01 -0700 Subject: [PATCH] [meshcop-leader] check `IsLeader()` processing `LeaderPetition/KeepAlive (#9531) This commit adds an `IsLeader()` check to ensure that the device is acting as the leader before processing `kUriLeaderPetition` or `kUriLeaderKeepAlive` TMF messages. This adds a safeguard to ensure that only the leader can update the commissioner dataset. --- src/core/meshcop/meshcop_leader.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/meshcop/meshcop_leader.cpp b/src/core/meshcop/meshcop_leader.cpp index 00a9e5eb877..08d99c6d6a6 100644 --- a/src/core/meshcop/meshcop_leader.cpp +++ b/src/core/meshcop/meshcop_leader.cpp @@ -73,6 +73,8 @@ template <> void Leader::HandleTmf(Coap::Message &aMessage, LogInfo("Received %s", UriToString()); + VerifyOrExit(Get().IsLeader()); + VerifyOrExit(Get().IsRoutingLocator(aMessageInfo.GetPeerAddr())); SuccessOrExit(Tlv::FindTlv(aMessage, commissionerId)); @@ -152,6 +154,8 @@ template <> void Leader::HandleTmf(Coap::Message &aMessage, LogInfo("Received %s", UriToString()); + VerifyOrExit(Get().IsLeader()); + SuccessOrExit(Tlv::Find(aMessage, state)); SuccessOrExit(Tlv::Find(aMessage, sessionId));