Skip to content

Commit

Permalink
Disallow CASE establishment attempts over existing secure sessions.
Browse files Browse the repository at this point in the history
Per spec, CASE establishment needs to happen via unauthenticated messages.  We
should ignore Sigma1 received over a CASE or PASE session.
  • Loading branch information
bzbarsky-apple committed Feb 27, 2023
1 parent af511d7 commit 689e525
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/protocols/secure_channel/CASEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,14 @@ CHIP_ERROR CASEServer::OnUnsolicitedMessageReceived(const PayloadHeader & payloa
CHIP_ERROR CASEServer::OnMessageReceived(Messaging::ExchangeContext * ec, const PayloadHeader & payloadHeader,
System::PacketBufferHandle && payload)
{
ChipLogProgress(Inet, "CASE Server received Sigma1 message. Starting handshake. EC %p", ec);
if (!ec->GetSessionHandle()->IsUnauthenticatedSesssion())
{
ChipLogError(Inet, "CASE Server received Sigma1 message %s EC %p", "over encrypted session. Ignoring.", ec);
return CHIP_ERROR_INCORRECT_STATE;
}

ChipLogProgress(Inet, "CASE Server received Sigma1 message %s EC %p", ". Starting handshake.", ec);

CHIP_ERROR err = InitCASEHandshake(ec);
SuccessOrExit(err);

Expand Down
2 changes: 2 additions & 0 deletions src/transport/Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ class Session

bool IsSecureSession() const { return GetSessionType() == SessionType::kSecure; }

bool IsUnauthenticatedSession() const { return GetSessionType() == SessionType::kUnauthenticated; }

void DispatchSessionEvent(SessionDelegate::Event event)
{
// Holders might remove themselves when notified.
Expand Down

0 comments on commit 689e525

Please sign in to comment.