Skip to content

fix: GraphQL API endpoint ignores CORS origin restriction (GHSA-q3p6-g7c4-829c)#10334

Merged
mtrezza merged 1 commit intoparse-community:alphafrom
mtrezza:fix/GHSA-q3p6-g7c4-829c-v9
Mar 27, 2026
Merged

fix: GraphQL API endpoint ignores CORS origin restriction (GHSA-q3p6-g7c4-829c)#10334
mtrezza merged 1 commit intoparse-community:alphafrom
mtrezza:fix/GHSA-q3p6-g7c4-829c-v9

Conversation

@mtrezza
Copy link
Copy Markdown
Member

@mtrezza mtrezza commented Mar 27, 2026

Issue

GraphQL API endpoint ignores CORS origin restriction (GHSA-q3p6-g7c4-829c)

@parse-github-assistant
Copy link
Copy Markdown

parse-github-assistant bot commented Mar 27, 2026

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

@parseplatformorg
Copy link
Copy Markdown
Contributor

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

The GraphQL server's CORS handling is refactored to use a dedicated allowCrossDomain middleware applied at the GraphQL path, replacing direct middleware usage and response header mutation in the Apollo context factory. Test expectations are updated accordingly, with comprehensive new tests validating CORS behavior across multiple configurations.

Changes

Cohort / File(s) Summary
CORS Middleware Refactoring
src/GraphQL/ParseGraphQLServer.js
Replaced direct CORS middleware usage with allowCrossDomain() middleware; removed response header mutation in Apollo context factory to delegate CORS handling to middleware layer.
CORS Test Coverage
spec/ParseGraphQLServer.spec.js, spec/vulnerabilities.spec.js
Updated existing test expectations for access-control-allow-origin behavior and added comprehensive new test suite verifying CORS handling for single/multiple allowOrigins, default wildcard, unauthorized origin rejection, and preflight requests.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is entirely missing. The required template includes sections for Issue, Approach, and Tasks that should be completed, but no description content was provided by the author. Provide a complete pull request description following the template, including the Issue being fixed, the Approach taken, and checked Tasks completed.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: GraphQL API endpoint ignores CORS origin restriction (GHSA-q3p6-g7c4-829c)' clearly and specifically describes the main change: fixing a CORS origin restriction vulnerability in the GraphQL API endpoint.

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

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

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
spec/vulnerabilities.spec.js (1)

5117-5131: Consider extracting the duplicated GraphQL test bootstrap helper.

This setup is very close to the helper used in the earlier GraphQL WebSocket security suite (Line 2736 onward). A shared helper would reduce drift between GraphQL vulnerability tests.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@spec/vulnerabilities.spec.js` around lines 5117 - 5131, The GraphQL test
bootstrap in setupGraphQLServer is duplicated from the earlier GraphQL WebSocket
suite; extract the shared behavior into a single helper (e.g.,
createSharedGraphQLTestServer) and have both suites call it. Move the logic that
closes existing httpServer, calls reconfigureServer(serverOptions), creates
express(), mounts server.app at '/parse', instantiates ParseGraphQLServer, calls
parseGraphQLServer.applyGraphQL(expressApp), starts httpServer.listen(gqlPort)
and returns the ParseGraphQLServer into that new helper, then replace the
current setupGraphQLServer implementation to delegate to the shared helper
(preserving use of symbols reconfigureServer, ParseGraphQLServer, applyGraphQL,
gqlPort and httpServer).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@spec/vulnerabilities.spec.js`:
- Around line 5117-5131: The GraphQL test bootstrap in setupGraphQLServer is
duplicated from the earlier GraphQL WebSocket suite; extract the shared behavior
into a single helper (e.g., createSharedGraphQLTestServer) and have both suites
call it. Move the logic that closes existing httpServer, calls
reconfigureServer(serverOptions), creates express(), mounts server.app at
'/parse', instantiates ParseGraphQLServer, calls
parseGraphQLServer.applyGraphQL(expressApp), starts httpServer.listen(gqlPort)
and returns the ParseGraphQLServer into that new helper, then replace the
current setupGraphQLServer implementation to delegate to the shared helper
(preserving use of symbols reconfigureServer, ParseGraphQLServer, applyGraphQL,
gqlPort and httpServer).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 88308ea8-1be9-42ef-a3a9-cb059fa0d789

📥 Commits

Reviewing files that changed from the base of the PR and between 5bb8ede and 8b441e9.

📒 Files selected for processing (3)
  • spec/ParseGraphQLServer.spec.js
  • spec/vulnerabilities.spec.js
  • src/GraphQL/ParseGraphQLServer.js

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.54%. Comparing base (776c71c) to head (8b441e9).
⚠️ Report is 3 commits behind head on alpha.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha   #10334   +/-   ##
=======================================
  Coverage   92.54%   92.54%           
=======================================
  Files         192      192           
  Lines       16519    16517    -2     
  Branches      229      229           
=======================================
- Hits        15287    15286    -1     
+ Misses       1212     1211    -1     
  Partials       20       20           

☔ View full report in Codecov by Sentry.
📢 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.

@mtrezza mtrezza changed the title fix: GHSA-q3p6-g7c4-829c v9 fix: GraphQL API endpoint ignores CORS origin restriction (GHSA-q3p6-g7c4-829c) Mar 27, 2026
@mtrezza mtrezza merged commit 4dd0d3d into parse-community:alpha Mar 27, 2026
24 checks passed
parseplatformorg pushed a commit that referenced this pull request Mar 27, 2026
# [9.7.0-alpha.10](9.7.0-alpha.9...9.7.0-alpha.10) (2026-03-27)

### Bug Fixes

* GraphQL API endpoint ignores CORS origin restriction ([GHSA-q3p6-g7c4-829c](GHSA-q3p6-g7c4-829c)) ([#10334](#10334)) ([4dd0d3d](4dd0d3d))
@parseplatformorg
Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 9.7.0-alpha.10

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

Labels

state:released-alpha Released as alpha version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants