Skip to content

Commit 168be64

Browse files
committed
[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 project-chip#34119
1 parent 03ae36e commit 168be64

File tree

2 files changed

+361
-2
lines changed

2 files changed

+361
-2
lines changed

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

+35
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,19 @@ void DoorLockServer::setCredentialCommandHandler(
788788
return;
789789
}
790790

791+
// return INVALID_COMMAND if the accessing fabric index doesn’t match the
792+
// CreatorFabricIndex of the credential being modified
793+
if (existingCredential.createdBy != fabricIdx)
794+
{
795+
ChipLogProgress(Zcl,
796+
"[createCredential] Unable to modify credential. Fabric index differs from creator fabric "
797+
"[endpointId=%d,credentialIndex=%d,creatorIdx=%d,modifierIdx=%d]",
798+
commandPath.mEndpointId, credentialIndex, existingCredential.createdBy, fabricIdx);
799+
800+
sendSetCredentialResponse(commandObj, commandPath, DlStatus::kInvalidField, 0, nextAvailableCredentialSlot);
801+
return;
802+
}
803+
791804
// if userIndex is NULL then we're changing the programming user PIN
792805
if (userIndex.IsNull())
793806
{
@@ -2192,6 +2205,17 @@ DlStatus DoorLockServer::createNewCredentialAndAddItToUser(chip::EndpointId endp
21922205
return DlStatus::kInvalidField;
21932206
}
21942207

2208+
// return INVALID_COMMAND if the accessing fabric index doesn’t match the
2209+
// CreatorFabricIndex in the user record pointed to by UserIndex
2210+
if (user.createdBy != modifierFabricIdx)
2211+
{
2212+
ChipLogProgress(Zcl,
2213+
"[createCredential] Unable to create credential for user created by different fabric "
2214+
"[endpointId=%d,userIndex=%d,creatorIdx=%d,fabricIdx=%d]",
2215+
endpointId, userIndex, user.createdBy, modifierFabricIdx);
2216+
return DlStatus::kInvalidField;
2217+
}
2218+
21952219
// Add new credential to the user
21962220
auto status = addCredentialToUser(endpointId, modifierFabricIdx, userIndex, credential);
21972221
if (DlStatus::kSuccess != status)
@@ -2312,6 +2336,17 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
23122336
return DlStatus::kFailure;
23132337
}
23142338

2339+
// return INVALID_COMMAND if the accessing fabric index doesn’t match the
2340+
// CreatorFabricIndex in the user record pointed to by UserIndex
2341+
if (user.createdBy != modifierFabricIdx)
2342+
{
2343+
ChipLogProgress(Zcl,
2344+
"[createCredential] Unable to modify credential for user created by different fabric "
2345+
"[endpointId=%d,userIndex=%d,creatorIdx=%d,fabricIdx=%d]",
2346+
endpointId, userIndex, user.createdBy, modifierFabricIdx);
2347+
return DlStatus::kInvalidField;
2348+
}
2349+
23152350
for (size_t i = 0; i < user.credentials.size(); ++i)
23162351
{
23172352
// appclusters, 5.2.4.40: user should already be associated with given credentialIndex

0 commit comments

Comments
 (0)