Skip to content

Commit 596741a

Browse files
authored
Impove CD validation (#29664)
We currently peform validation against PAA checks in encoding. In decoding, we check for cryptographic validity, but do not perform the same checks againts the data. This commit brings the encoding and decoding into parity.
1 parent 11c3dec commit 596741a

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/credentials/CertificationDeclaration.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ CHIP_ERROR DecodeCertificationElements(const ByteSpan & encodedCertElements, Cer
143143
certElements.ProductIdsCount = 0;
144144
while ((err = reader.Next(AnonymousTag())) == CHIP_NO_ERROR)
145145
{
146+
VerifyOrReturnError(certElements.ProductIdsCount < kMaxProductIdsCount, CHIP_ERROR_INVALID_ARGUMENT);
146147
ReturnErrorOnFailure(reader.Get(certElements.ProductIds[certElements.ProductIdsCount++]));
147148
}
148149
VerifyOrReturnError(err == CHIP_END_OF_TLV, err);
@@ -194,6 +195,7 @@ CHIP_ERROR DecodeCertificationElements(const ByteSpan & encodedCertElements, Cer
194195
while ((err = reader.Next(kTLVType_ByteString, AnonymousTag())) == CHIP_NO_ERROR)
195196
{
196197
VerifyOrReturnError(reader.GetLength() == kKeyIdentifierLength, CHIP_ERROR_UNEXPECTED_TLV_ELEMENT);
198+
VerifyOrReturnError(certElements.AuthorizedPAAListCount < kMaxAuthorizedPAAListCount, CHIP_ERROR_INVALID_ARGUMENT);
197199

198200
ReturnErrorOnFailure(
199201
reader.GetBytes(certElements.AuthorizedPAAList[certElements.AuthorizedPAAListCount++], kKeyIdentifierLength));

0 commit comments

Comments
 (0)