Skip to content

test: Connect LiveQuery security specs to the test server - #10897

Open
Goldloli wants to merge 1 commit into
parse-community:alphafrom
Goldloli:fix/livequery-security-spec-server-url
Open

Goldloli wants to merge 1 commit into
parse-community:alphafrom
Goldloli:fix/livequery-security-spec-server-url

Conversation

@Goldloli

@Goldloli Goldloli commented Nov 23, 2026 •

Copy link
Copy Markdown

Issue

Fixes #10720

Two specs in spec/vulnerabilities.spec.js create a Parse.LiveQueryClient with serverURL: 'ws://localhost:1337'. The test server runs its LiveQuery server on the Parse Server port 8378 (startLiveQueryServer: true without liveQueryServerOptions.port), and nothing listens on port 1337.

Approach

Point both clients at ws://localhost:8378, the port the test server's LiveQuery server actually listens on, and wait for the subscription ACK before asserting.

Without the ACK wait, the ReDoS spec would still pass on a wrong URL: it asserts that the create event times out, which is also true when the subscription never reaches the server. Waiting for open makes the spec fail if the subscribe request does not reach the server.

  • (GHSA-mf3j-86qx-cq5j) ReDoS via $regex in LiveQuery subscription: the subscription now reaches the server, so the timeout assertion measures the regex timeout protection instead of a dead client.
  • (GHSA-fjxm-vhvc-gcmj) LiveQuery Operator Type Confusion > LiveQuery integration: the malformed query now reaches the server; if the server rejected it, the ACK wait fails the spec.

Verification

Environment: Node 24.12.0, MongoDB 8.0.4 (mongodb-runner, standalone), TESTING=1.

  1. Baseline on alpha (specs unchanged): the ReDoS spec passes in 5.1 s, which is exactly its 5000 ms timeout — consistent with a client that never connects.
  2. With the fix: npx jasmine spec/vulnerabilities.spec.js — 915 specs, 0 failures, 23 pending. All LiveQuery-filtered specs: 160 specs, 0 failures.
  3. Mutation checks, each reverted afterwards:
    • Reverting only the server URL to ws://localhost:1337 makes both specs fail (the ACK wait times out), confirming the specs now depend on a real connection.
    • Disabling the server-side regex timeout in lib/LiveQuery/QueryTools.js (if (!regexTimeout) → if (true)) makes the ReDoS spec fail with Expected 34812 to be less than 6000, confirming the spec now covers the protection.
    • The original spec plus that same disabled protection still passes, which reproduces the issue: the spec passed without the protection being exercised.
  4. npm run lint passes.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK

Summary by CodeRabbit

  • Tests
    • Updated two LiveQuery tests to connect to the local test server and wait for the subscription to open before proceeding. This makes the tests reflect the subscription’s connection state.

Two specs in spec/vulnerabilities.spec.js created a Parse.LiveQueryClient
with serverURL 'ws://localhost:1337'. The test server runs its LiveQuery
server on the Parse Server port 8378, and nothing listens on 1337, so the
clients never connected:

- The ReDoS spec asserted that the create event times out. That assertion
  also holds when the subscription never reaches the server, so the spec
  did not cover the regex timeout protection.
- The type confusion spec subscribed with a malformed query through such a
  client, so the malformed query never reached the server.

Point both clients at ws://localhost:8378 and wait for the subscription
ACK before asserting, so the specs fail when the subscribe request does
not reach the server.
@parse-github-assistant

Copy link
Copy Markdown

I will reformat the title to use the proper commit message syntax.

@parse-github-assistant parse-github-assistant Bot changed the title test: connect LiveQuery security specs to the test server test: Connect LiveQuery security specs to the test server Nov 23, 2026
@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 Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Two LiveQuery security specs now connect to the server on port 8378. Each waits for the subscription’s open event before continuing.

Changes: LiveQuery security specs

Layer / File(s) Summary
Connect and subscribe
spec/vulnerabilities.spec.js
The ReDoS and malformed-operator specs use ws://localhost:8378. Both retain the subscription returned by subscribe() and wait for its open event.

Estimated code review effort: 2 (Simple) | ~8 minutes

Severity of issue fixed: Low

Suggested reviewers: mtrezza

Merge Risk: Minimal · up to 7e1c6

This updates two LiveQuery security specs so they connect to the correct server port and wait for the subscription to be established. Production behavior is unaffected, and there is no identified merge-blocking risk.

Pre-merge checks: Passed 6

Check name Status Explanation
Title check Passed The title begins with the required prefix "test:" and the first word after the prefix is capitalized ("Connect"). It describes the main change, which points two LiveQuery security specs at the port wh…
Description check Passed The description follows the template. It includes the Issue section (Fixes #10720), an Approach section that explains the URL change and the ACK wait, a Tasks section with the 'Add tests' item checked…
Linked Issues check Passed Issue #10720 requires the two LiveQuery security specs to connect to the LiveQuery server and to exercise their subscriptions. The diff to spec/vulnerabilities.spec.js meets both points:

- (GHSA-mf3j…
Out of Scope Changes check Passed The whole-PR diff against the merge base changes only spec/vulnerabilities.spec.js. Its hunks are the two URL changes (1337 to 8378) and the two ACK waits. Each hunk applies directly to the linked iss…
Security Check Passed The PR changes one file, spec/vulnerabilities.spec.js, with +10/-4 lines in two LiveQuery test specs. The diff only changes the test client's serverURL from ws://localhost:1337 to `ws://localhos…
Engage In Review Feedback Passed The check requires that the author engage with review feedback before ignoring or resolving it. The supplied review context contains no feedback to engage with. - Posted review comments: the context s…
Full details: Title check

Explanation

The title begins with the required prefix "test:" and the first word after the prefix is capitalized ("Connect"). It describes the main change, which points two LiveQuery security specs at the port where the test server's LiveQuery server listens.

Full details: Description check

Explanation

The description follows the template. It includes the Issue section (Fixes #10720), an Approach section that explains the URL change and the ACK wait, a Tasks section with the 'Add tests' item checked, and the remaining unchecked tasks. The template's standard license and security links are not present, and the documentation, security check, and Parse Error code items are unchecked without explanation. These gaps are non-critical, so the description is mostly complete.

Full details: Linked Issues check

Explanation

Issue #10720 requires the two LiveQuery security specs to connect to the LiveQuery server and to exercise their subscriptions. The diff to spec/vulnerabilities.spec.js meets both points:

  • (GHSA-mf3j-86qx-cq5j) ReDoS spec, does not block event loop with catastrophic backtracking regex in LiveQuery: the client URL changes from ws://localhost:1337 to ws://localhost:8378. The spec now keeps the subscription object and awaits its 'open' event before creating the object that triggers regex evaluation. A subscribe request that never reaches the server now fails the spec.
  • (GHSA-fjxm-vhvc-gcmj) Type Confusion spec, server does not crash and other subscriptions work when type-confused subscription exists: the malformed-query client uses ws://localhost:8378. The spec awaits the 'open' event of the malformed subscription before it subscribes with the valid query. The malformed query therefore reaches the server before the assertions run.

The issue text also says that LiveQueryClient.close() does not cancel a pending reconnect. The issue presents this as context, and the title and the directly stated fix concern the connection target. The PR does not change that behavior, and this assessment does not require it.

The PR author reports test runs and mutation checks. I did not run them. The diff evidence matches the described change.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base changes only spec/vulnerabilities.spec.js. Its hunks are the two URL changes (1337 to 8378) and the two ACK waits. Each hunk applies directly to the linked issue #10720. No library code, documentation, or unrelated tests change. The PR description reports a temporary mutation to lib/LiveQuery/QueryTools.js, but the reviewed diff does not contain that file, so that edit was reverted as the author states.

Full details: Security Check

Explanation

The PR changes one file, spec/vulnerabilities.spec.js, with +10/-4 lines in two LiveQuery test specs. The diff only changes the test client's serverURL from ws://localhost:1337 to ws://localhost:8378. It also replaces await client.subscribe(query) with a subscription handle that waits for its open event. I checked the committed diff against the base and found no production code, no lib/ changes, and no dependency or configuration changes. The new code does not match any security pattern from the custom check: - The hardcoded localhost URL is a test-only endpoint. It is not a credential, secret, or exposed interface. - The new open wait changes only test timing and assertion coverage. It does not change server behavior, authentication, authorization, input validation, or regex protection. - The spec still sends a malformed query to a local test server. That is the intended test behavior, not a new attack surface. No failure condition in the custom check applies to this change.

Full details: Engage In Review Feedback

Explanation

The check requires that the author engage with review feedback before ignoring or resolving it. The supplied review context contains no feedback to engage with. - Posted review comments: the context states "No CodeRabbit review threads were returned." No thread exists that the author could have ignored or resolved. - Current review findings: the context states the current review "produced zero actionable findings." No finding is open, unaddressed, or closed without discussion. The current-review result covers only that review. The context does not show earlier posted threads, so I cannot rule out earlier feedback. The supplied data does not show any. On the evidence provided, no feedback was ignored or resolved without engagement, so the check passes. I did not run repository tools. The supplied review metadata decides this check, as the instructions permit for metadata-only criteria.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.3)

spec/vulnerabilities.spec.js

ast-grep timed out on this file

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9d55ba45-a21b-476c-8a85-c23097a377e1
Commits

Reviewing files that changed from the base of the PR and between a3f152f and 7e1c666.

Files selected for processing: 1

  • spec/vulnerabilities.spec.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

This branch has not been deployed

No deployments
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.

Two LiveQuery security specs never connect to the LiveQuery server

1 participant