Skip to content

Commit 0d71711

Browse files
jrhees-caerestyled-commitsandy31415
authored
[DRLK] Bugfix: return INVALID_COMMAND when attempting to add/modify (#34120)
* [DRLK] Bugfix: return INVALID_COMMAND when attempting to add/modify credential from a different fabric than the User/Credential's creator fabric Add YAML test steps to verify correct behavior Fixes #34119 * Restyled by prettier-yaml * Update src/app/tests/suites/DL_UsersAndCredentials.yaml Co-authored-by: Andrei Litvin <andy314@gmail.com> --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Andrei Litvin <andy314@gmail.com>
1 parent 9d8587d commit 0d71711

File tree

2 files changed

+365
-3
lines changed

2 files changed

+365
-3
lines changed

src/app/clusters/door-lock-server/door-lock-server.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,19 @@ void DoorLockServer::setCredentialCommandHandler(
803803
return;
804804
}
805805

806+
// return INVALID_COMMAND if the accessing fabric index doesn’t match the
807+
// CreatorFabricIndex of the credential being modified
808+
if (existingCredential.createdBy != fabricIdx)
809+
{
810+
ChipLogProgress(Zcl,
811+
"[createCredential] Unable to modify credential. Fabric index differs from creator fabric "
812+
"[endpointId=%d,credentialIndex=%d,creatorIdx=%d,modifierIdx=%d]",
813+
commandPath.mEndpointId, credentialIndex, existingCredential.createdBy, fabricIdx);
814+
815+
sendSetCredentialResponse(commandObj, commandPath, DlStatus::kInvalidField, 0, nextAvailableCredentialSlot);
816+
return;
817+
}
818+
806819
// if userIndex is NULL then we're changing the programming user PIN
807820
if (userIndex.IsNull())
808821
{
@@ -2218,6 +2231,17 @@ DlStatus DoorLockServer::createNewCredentialAndAddItToUser(chip::EndpointId endp
22182231
return DlStatus::kInvalidField;
22192232
}
22202233

2234+
// return INVALID_COMMAND if the accessing fabric index doesn’t match the
2235+
// CreatorFabricIndex in the user record pointed to by UserIndex
2236+
if (user.createdBy != modifierFabricIdx)
2237+
{
2238+
ChipLogProgress(Zcl,
2239+
"[createCredential] Unable to create credential for user created by different fabric "
2240+
"[endpointId=%d,userIndex=%d,creatorIdx=%d,fabricIdx=%d]",
2241+
endpointId, userIndex, user.createdBy, modifierFabricIdx);
2242+
return DlStatus::kInvalidField;
2243+
}
2244+
22212245
// Add new credential to the user
22222246
auto status = addCredentialToUser(endpointId, modifierFabricIdx, userIndex, credential);
22232247
if (DlStatus::kSuccess != status)
@@ -2338,6 +2362,17 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
23382362
return DlStatus::kFailure;
23392363
}
23402364

2365+
// return INVALID_COMMAND if the accessing fabric index doesn’t match the
2366+
// CreatorFabricIndex in the user record pointed to by UserIndex
2367+
if (user.createdBy != modifierFabricIdx)
2368+
{
2369+
ChipLogProgress(Zcl,
2370+
"[createCredential] Unable to modify credential for user created by different fabric "
2371+
"[endpointId=%d,userIndex=%d,creatorIdx=%d,fabricIdx=%d]",
2372+
endpointId, userIndex, user.createdBy, modifierFabricIdx);
2373+
return DlStatus::kInvalidField;
2374+
}
2375+
23412376
for (size_t i = 0; i < user.credentials.size(); ++i)
23422377
{
23432378
// appclusters, 5.2.4.40: user should already be associated with given credential

0 commit comments

Comments
 (0)