@@ -788,6 +788,19 @@ void DoorLockServer::setCredentialCommandHandler(
788
788
return ;
789
789
}
790
790
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
+
791
804
// if userIndex is NULL then we're changing the programming user PIN
792
805
if (userIndex.IsNull ())
793
806
{
@@ -2192,6 +2205,17 @@ DlStatus DoorLockServer::createNewCredentialAndAddItToUser(chip::EndpointId endp
2192
2205
return DlStatus::kInvalidField ;
2193
2206
}
2194
2207
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
+
2195
2219
// Add new credential to the user
2196
2220
auto status = addCredentialToUser (endpointId, modifierFabricIdx, userIndex, credential);
2197
2221
if (DlStatus::kSuccess != status)
@@ -2312,6 +2336,17 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
2312
2336
return DlStatus::kFailure ;
2313
2337
}
2314
2338
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
+
2315
2350
for (size_t i = 0 ; i < user.credentials .size (); ++i)
2316
2351
{
2317
2352
// appclusters, 5.2.4.40: user should already be associated with given credentialIndex
0 commit comments