fix: Protected fields leak via LiveQuery afterEvent trigger (GHSA-5hmj-jcgp-6hff)#10232
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📝 WalkthroughWalkthroughAdds a LiveQuery security test suite for protected fields and updates LiveQuery server handlers to propagate trigger-applied JSON transformations back into payloads before filtering and pushing to clients. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant LiveQueryServer as LiveQuery Server
participant Trigger as afterLiveQueryEvent Trigger
participant Store as DataStore
Client->>LiveQueryServer: Subscribe / receives event
Store->>LiveQueryServer: Emit raw event (object)
LiveQueryServer->>Trigger: run afterLiveQueryEvent(res)
Trigger-->>LiveQueryServer: res.object / res.original (possibly transformed)
LiveQueryServer->>LiveQueryServer: toJSONwithObjects + assign transformed object
LiveQueryServer->>LiveQueryServer: apply data filtering (remove protected fields)
LiveQueryServer-->>Client: push filtered event
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10232 +/- ##
=======================================
Coverage 92.60% 92.60%
=======================================
Files 192 192
Lines 16341 16347 +6
Branches 200 201 +1
=======================================
+ Hits 15132 15138 +6
Misses 1192 1192
Partials 17 17 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/LiveQuery/ParseLiveQueryServer.ts (1)
249-262:⚠️ Potential issue | 🟠 MajorKeep the filtered payload request-scoped.
Line 261 and Lines 419-430 write a per-client filtered object back into
deletedParseObject,currentParseObject, andoriginalParseObject, but those variables live outsiderequestIds.forEach(async ...). Once one restricted subscriber runs first, later subscribers can reuse that redacted copy and miss fields they are allowed to see.💡 Suggested fix
- if (res.object && typeof res.object.toJSON === 'function') { - deletedParseObject = toJSONwithObjects(res.object, res.object.className || className); - } - res.object = deletedParseObject; + let payloadObject = structuredClone(deletedParseObject); + if (res.object && typeof res.object.toJSON === 'function') { + payloadObject = toJSONwithObjects(res.object, res.object.className || className); + } + res.object = payloadObject; await this._filterSensitiveData( classLevelPermissions, res, client, requestId, op, subscription.query ); - deletedParseObject = res.object; - client.pushDelete(requestId, deletedParseObject); + payloadObject = res.object; + client.pushDelete(requestId, payloadObject);- if (res.object && typeof res.object.toJSON === 'function') { - currentParseObject = toJSONwithObjects(res.object, res.object.className || className); - } - if (res.original && typeof res.original.toJSON === 'function') { - originalParseObject = toJSONwithObjects( - res.original, - res.original.className || className - ); - } - res.object = currentParseObject; - res.original = originalParseObject; + let payloadObject = structuredClone(currentParseObject); + let payloadOriginal = structuredClone(originalParseObject); + if (res.object && typeof res.object.toJSON === 'function') { + payloadObject = toJSONwithObjects(res.object, res.object.className || className); + } + if (res.original && typeof res.original.toJSON === 'function') { + payloadOriginal = toJSONwithObjects( + res.original, + res.original.className || className + ); + } + res.object = payloadObject; + res.original = payloadOriginal; await this._filterSensitiveData( classLevelPermissions, res, client, requestId, op, subscription.query ); - currentParseObject = res.object; - originalParseObject = res.original ?? null; + payloadObject = res.object; + payloadOriginal = res.original ?? null; const functionName = 'push' + res.event.charAt(0).toUpperCase() + res.event.slice(1); if (client[functionName]) { - client[functionName](requestId, currentParseObject, originalParseObject); + client[functionName](requestId, payloadObject, payloadOriginal); }Also applies to: 410-433
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/LiveQuery/ParseLiveQueryServer.ts` around lines 249 - 262, The code is mutating outer-scope variables (deletedParseObject, currentParseObject, originalParseObject) with the per-client filtered result from _filterSensitiveData, causing subsequent subscribers to see an already-redacted object; instead, create a request-scoped variable (e.g., filteredDeleted, filteredCurrent, filteredOriginal) inside the requestIds.forEach/async handler, pass that into _filterSensitiveData (or clone res.object into a local var before filtering), and use those local filtered values when calling client.pushDelete / client.pushCreate / client.pushUpdate so the outer originals remain unchanged for other subscribers; update all places referencing deletedParseObject/currentParseObject/originalParseObject within the subscriber loop to use the local filtered* variables.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/LiveQuery/ParseLiveQueryServer.ts`:
- Around line 249-262: The code is mutating outer-scope variables
(deletedParseObject, currentParseObject, originalParseObject) with the
per-client filtered result from _filterSensitiveData, causing subsequent
subscribers to see an already-redacted object; instead, create a request-scoped
variable (e.g., filteredDeleted, filteredCurrent, filteredOriginal) inside the
requestIds.forEach/async handler, pass that into _filterSensitiveData (or clone
res.object into a local var before filtering), and use those local filtered
values when calling client.pushDelete / client.pushCreate / client.pushUpdate so
the outer originals remain unchanged for other subscribers; update all places
referencing deletedParseObject/currentParseObject/originalParseObject within the
subscriber loop to use the local filtered* variables.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6c29a206-9123-40da-b14f-2f5c6381b3dc
📒 Files selected for processing (1)
src/LiveQuery/ParseLiveQueryServer.ts
# [9.6.0-alpha.35](9.6.0-alpha.34...9.6.0-alpha.35) (2026-03-17) ### Bug Fixes * Protected fields leak via LiveQuery afterEvent trigger ([GHSA-5hmj-jcgp-6hff](GHSA-5hmj-jcgp-6hff)) ([#10232](#10232)) ([6648500](6648500))
|
🎉 This change has been released in version 9.6.0-alpha.35 |
Issue
Protected fields leak via LiveQuery afterEvent trigger (GHSA-5hmj-jcgp-6hff)
Tasks