fix: prevent cross-user data exposure in IndexedDB operations (closes #885)#886
Open
namann5 wants to merge 1 commit into
Open
fix: prevent cross-user data exposure in IndexedDB operations (closes #885)#886namann5 wants to merge 1 commit into
namann5 wants to merge 1 commit into
Conversation
- Filter local records by userId in updateLocalWorkoutsFromFirestore using the userId index instead of loading all records via store.getAll() - Add userId ownership validation in deleteWorkout before allowing deletion Closes Somil450#885
|
@namann5 is attempting to deploy a commit to the somiljain2024-4175's projects Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
|
@namann5 Make ci pipeline checks green. |
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.
Description
Fixes a critical privacy vulnerability where \updateLocalWorkoutsFromFirestore\ loads all local IndexedDB records across all users via \store.getAll(), exposing cross-user workout data in memory on shared devices. Also fixes an authorization gap in \deleteWorkout()\ where the \userId\ parameter was accepted but never validated.
Changes
\src/services/workoutSyncService.ts\
**\updateLocalWorkoutsFromFirestore**: Replaced \store.getAll()\ (loads every record across all users) with \store.index('userId').getAll(IDBKeyRange.only(userId))\ — only the current user's local records are loaded into memory.
**\deleteWorkout**: Added an ownership check — before deleting, fetches the record and verifies
ecord.userId === userId. If the IDs don't match, the deletion is rejected.
Impact
Related
Closes #885