Skip to content

Commit

Permalink
Disallow CASE and PASE establishment attempts over existing secure se…
Browse files Browse the repository at this point in the history
…ssions. (#25349)

Per spec, CASE and PASE establishment needs to happen via unauthenticated
messages.  We should ignore Sigma1 or PBKDFParamsRequest received over a CASE or
PASE (or group) session.
  • Loading branch information
bzbarsky-apple authored Feb 27, 2023
1 parent 07e7a0e commit 11c2f5b
Show file tree
Hide file tree
Showing 3 changed files with 17 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()->IsUnauthenticatedSession())
{
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
7 changes: 7 additions & 0 deletions src/protocols/secure_channel/PASESession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,13 @@ CHIP_ERROR PASESession::ValidateReceivedMessage(ExchangeContext * exchange, cons
{
mExchangeCtxt = exchange;
}

if (!mExchangeCtxt->GetSessionHandle()->IsUnauthenticatedSession())
{
ChipLogError(SecureChannel, "PASESession received PBKDFParamRequest over encrypted session. Ignoring.");
return CHIP_ERROR_INCORRECT_STATE;
}

mExchangeCtxt->UseSuggestedResponseTimeout(kExpectedHighProcessingTime);

VerifyOrReturnError(!msg.IsNull(), CHIP_ERROR_INVALID_ARGUMENT);
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 11c2f5b

Please sign in to comment.