Skip to content

fix: GHSA-cgxm-vr2f-6fj8#10511

Open
mtrezza wants to merge 2 commits into
parse-community:alphafrom
mtrezza:fix/GHSA-cgxm-vr2f-6fj8-v9
Open

fix: GHSA-cgxm-vr2f-6fj8#10511
mtrezza wants to merge 2 commits into
parse-community:alphafrom
mtrezza:fix/GHSA-cgxm-vr2f-6fj8-v9

Conversation

@mtrezza

@mtrezza mtrezza commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Bug Fixes

    • Improved query depth validation across LiveQuery subscriptions and REST queries, correctly enforcing nesting limits for deeply nested logical operators while handling field-level operator wrapping more accurately.
    • Fixed query-depth traversal to avoid redundant nested array re-walking, helping maintain performance consistency.
  • Tests

    • Added and expanded coverage to validate rejection/acceptance scenarios for complex $or nesting, including invalid non-array inputs and depth-disabled behavior.

@parse-github-assistant

Copy link
Copy Markdown

🚀 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

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

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. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd3609ca-9cfe-4a96-a10b-6efbc9f5498e

📥 Commits

Reviewing files that changed from the base of the PR and between 35ddb12 and d4050ee.

📒 Files selected for processing (1)
  • spec/ParseLiveQueryServer.spec.js

📝 Walkthrough

Walkthrough

The PR fixes a queryDepth bypass where deeply nested $or/$and/$nor structures hidden inside field-level operators ($elemMatch, $not, plain field names) were not traversed by the validator. Both RestQuery.js and ParseLiveQueryServer.ts replace their narrow logical-operator-only recursion with a general checkDepth walker that descends all object keys, incrementing depth only at logical operators. Tests are added for rejection, acceptance, and performance.

Changes

queryDepth bypass fix and tests

Layer / File(s) Summary
Generalized checkDepth walker
src/RestQuery.js, src/LiveQuery/ParseLiveQueryServer.ts
validateQueryDepth and _handleSubscribe both replace their $or/$and/$nor-only traversal with a full recursive walker that descends all object keys, traverses arrays at the same depth, increments depth only on logical operators, and validates those operators hold arrays. findObjectWithKey also gains an early return after array traversal to avoid re-walking.
Field-wrapped depth bypass tests
spec/RequestComplexity.spec.js, spec/ParseLiveQueryServer.spec.js
New tests assert that deeply nested $or inside $elemMatch, $not, and plain field names is rejected at the configured depth, that structures within the limit are accepted, that $in arrays don't count toward depth, and that queryDepth:-1 does not cause exponential processing time. LiveQuery tests verify INVALID_QUERY is sent and no subscription is created when $or is buried, and confirm proper handling of non-array $or values and null values within allowed depth.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is completely missing; no description text was provided by the author. Add a pull request description following the repository template, including sections for Issue, Approach, and completed Tasks.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Engage In Review Feedback ❓ Inconclusive Cannot verify review feedback engagement without access to GitHub PR comments; sandboxed git repository contains single commit with no review discussion markers or subsequent engagement commits vis... Access to live GitHub PR #10511 API or comment data needed to verify whether review feedback exists and how it was engaged with by the author.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title follows the required format with the 'fix:' prefix and references a security vulnerability identifier (GHSA-cgxm-vr2f-6fj8), which is directly related to the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Security Check ✅ Passed The PR properly implements GHSA-cgxm-vr2f-6fj8 fix with consistent query depth validation in both LiveQuery and REST APIs, correctly detecting field-wrapped logical operators, validating array requ...

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.22.0)

OpenGrep fatal error (exit code 2): [00.19][ERROR]: Error: exception Unix_error: No such file or directory stat spec/ParseLiveQueryServer.spec.js
Raised by primitive operation at UTmp.replace_named_pipe_by_regular_file_if_needed in file "libs/commons/UTmp.ml", line 145, characters 8-27
Called from Scan_CLI.replace_target_roots_by_regular_files_where_needed.(fun) in file "src/osemgrep/cli_scan/Scan_CLI.ml", lines 1086-1087, characters 19-65
Called from List_.fast_map in file "libs/commons/List_.ml", line 81, characters 17-20
Called


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 16, 2026
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.65%. Comparing base (be12a60) to head (d4050ee).
⚠️ Report is 1 commits behind head on alpha.

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha   #10511      +/-   ##
==========================================
+ Coverage   92.62%   92.65%   +0.03%     
==========================================
  Files         193      193              
  Lines       16954    16961       +7     
  Branches      240      242       +2     
==========================================
+ Hits        15703    15715      +12     
+ Misses       1228     1225       -3     
+ Partials       23       21       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant