Skip to content

fix: prevent prototype pollution via session archive decompression (closes #922)#923

Open
namann5 wants to merge 3 commits into
Somil450:mainfrom
namann5:fix/prototype-pollution-session-archive
Open

fix: prevent prototype pollution via session archive decompression (closes #922)#923
namann5 wants to merge 3 commits into
Somil450:mainfrom
namann5:fix/prototype-pollution-session-archive

Conversation

@namann5

@namann5 namann5 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes a critical prototype pollution vulnerability (CWE-1321) discovered in the session archive decompression pipeline.

Vulnerabilities Fixed

1. Prototype Pollution in sessionRecorder.ts - RLDCompressionDriver.applyDelta()

The ensureLandmark() method indexed into the landmarks array using entry.index without validating the index type or bounds. A malicious archive with index: "__proto__" would:

  • Bypass the bounds check (string-to-number coercion produces NaN)
  • Return Array.prototype instead of a landmark object
  • Allow polluting Object.prototype via property assignment

Fix: Added isSafeIndex() guard (validates non-negative integer < 10000) and isSafeKey() guard (filters __proto__, constructor, prototype keys).

2. Missing Input Sanitization in workoutSyncService.ts

Multiple functions spread external WorkoutRecord objects (saveWorkoutLocally, markWorkoutAsSynced, updateLocalWorkoutsFromFirestore) without sanitizing against prototype pollution keys.

Fix: Added sanitizeRecord() helper that strips dangerous keys before object spread operations.

Changes

File Change
src/services/sessionRecorder.ts Added isSafeIndex(), isSafeKey(), guarded ensureLandmark() and applyDelta() property access
src/services/workoutSyncService.ts Added sanitizeRecord(), applied to all object spread operations from external data

Testing

  • isSafeIndex rejects strings, negative numbers, floats, and values >= 10000
  • isSafeKey rejects __proto__, constructor, prototype
  • Existing session archive compression/decompression unaffected (indices are always valid numbers)

Closes #922

namann5 added 3 commits May 27, 2026 20:48
- Add SOCKET_AUTH_TOKEN middleware for Socket.IO authentication
- Enforce per-IP connection limits via MAX_CONNECTIONS_PER_IP
- Rate-limit pose frames to MAX_FRAMES_PER_SEC per connection
- Parse comma-separated CORS origins with production wildcard warning
- Add unit tests for cors config, socket config, and frame rate limiting
- Add integration tests for socket auth (reject, accept, unset)
- Bump socket.io-client 4.8.1→4.8.3, supertest 7.0.0→7.2.2
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CRITICAL] Prototype Pollution via Malicious Session Archive in sessionRecorder.ts

1 participant