Repository navigation
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Enrollment retries can bypass uniqueness checks during pending verification or after failed cleanup, allowing duplicate face enrollments.
2 open issues
What changed in this PR
This PR addresses FaceTec same-face enrollment races across wallets by adding a post-index uniqueness check without a distributed lock.
Changes:
- Checks for duplicates before and after indexing.
- Attempts cleanup after post-index failures or indexing timeouts.
- Adds concurrency and cleanup tests and updates existing expectations.
| File | Description |
|---|---|
src/server/verification/processor/provider/ZoomProvider.js |
Adds post-index duplicate detection and cleanup handling. |
src/server/verification/processor/provider/__tests__/ZoomProvider.js |
Covers concurrent enrollments and cleanup, and adjusts callback expectations. |
Review effort: Balanced
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| }, | ||
| zoomEnrollmentLockLeaseSeconds: { | ||
| doc: 'Lease duration in seconds for the global FaceTec uniqueness check + indexing lock', | ||
| format: 'nat', |
|
|
||
| // if not already enrolled or indexed - indexing | ||
| try { | ||
| await api.indexEnrollment(enrollmentIdentifier, defaultSearchIndexName, customLogger) |
Comment on lines
+161
to
+164
| const acquired = await this.store.tryAcquire(name, owner, leaseMs) | ||
|
|
||
| if (acquired) { | ||
| return this._createLease(name, owner, leaseMs) |
| throwException(message, { isEnrolled }, response) | ||
| } | ||
| // 3. checking for duplicates | ||
| const { results, ...faceSearchResponse } = await api.faceSearch( |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Serialize the FaceTec uniqueness search + 3D index insertion critical section across all enrollment identifiers using a global distributed lock (
facetec-uniqueness:<indexName>).REDISCLOUD_URLviaSET ... PX ... NX+ Lua owner-checked renew/release) when configured, falling back to MongoDB (findOneAndUpdatelease document with periodic renewal andassertOwned()verification before indexing).indexed == verified uniqueinvariant (unverified enrollments are never speculatively indexed), eliminating same-identifier pending-window and failed-cleanup bypasses.isEnrollmentIndexedinside the lock whenalreadyEnrolledis true so concurrent requests for the same identifier do not double-search or double-index.ZOOM_ENROLLMENT_LOCK_LEASE_SECONDSandZOOM_ENROLLMENT_LOCK_TIMEOUT_SECONDSsettings.Tests
DistributedEnrollmentLockcovering bothMongoLockStoreandRedisLockStore(serialization, acquisition timeout, stale-owner lease protection).ZoomProvidercovering cross-wallet duplicate serialization and same-identifier concurrent requests.Summary by Sourcery
Serialize FaceTec uniqueness checks and indexing so concurrent enrollments cannot bypass duplicate detection.
New Features:
Bug Fixes:
Enhancements:
Tests:
Chores: