Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit cffea1f

Browse files
emargolisrobszewczyk
authored andcommitted
Prevent Integer Overflow When Decoding CASE Request Message.
-- The msgLenWithoutSig variable in BeginSessionRequestContext::DecodeHead() function was promoted from uint16_t to uint32_t to prevent integer overflow, which may result in denial-of-service vulnerability. This change addresses CVE security vulnerability: CVE-2019-5037
1 parent 42c1515 commit cffea1f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/lib/profiles/security/WeaveCASEMessages.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ WEAVE_ERROR BeginSessionRequestContext::DecodeHead(PacketBuffer *msgBuf)
109109
WEAVE_ERROR err = WEAVE_NO_ERROR;
110110
uint8_t *p = msgBuf->Start();
111111
uint16_t msgLen = msgBuf->DataLength();
112-
uint16_t msgLenWithoutSig;
112+
uint32_t msgLenWithoutSig;
113113
uint8_t controlHeader;
114114

115115
// Verify we can read the fixed length portion of the message without running into the end of the buffer.
@@ -144,7 +144,8 @@ WEAVE_ERROR BeginSessionRequestContext::DecodeHead(PacketBuffer *msgBuf)
144144
SessionKeyId = LittleEndian::Read16(p);
145145

146146
// Verify the overall message length is consistent with the claimed field sizes.
147-
msgLenWithoutSig = HeadLength() + ECDHPublicKey.ECPointLen + CertInfoLength + PayloadLength;
147+
// Promote the first rightside component to uint32_t. The rest should be promoted automatically.
148+
msgLenWithoutSig = static_cast<uint32_t>(HeadLength()) + ECDHPublicKey.ECPointLen + CertInfoLength + PayloadLength;
148149
VerifyOrExit(msgLen > msgLenWithoutSig, err = WEAVE_ERROR_MESSAGE_INCOMPLETE);
149150

150151
// Parse the alternate configs list.

0 commit comments

Comments
 (0)