Skip to content

feat: Add option to disallow aggregation pipelines for the read-only master key#10517

Merged
mtrezza merged 1 commit into
parse-community:alphafrom
mtrezza:feat/read-only-master-key-aggregation
Jun 19, 2026
Merged

feat: Add option to disallow aggregation pipelines for the read-only master key#10517
mtrezza merged 1 commit into
parse-community:alphafrom
mtrezza:feat/read-only-master-key-aggregation

Conversation

@mtrezza

@mtrezza mtrezza commented Jun 19, 2026

Copy link
Copy Markdown
Member

Issue

The readOnlyMasterKey is intended to provide read-only access. However, it can run aggregation pipelines via the aggregate endpoint, and an aggregation pipeline can contain write-capable stages (for example MongoDB $out and $merge). There is currently no way for an operator to prevent the read-only master key from running aggregation pipelines.

Approach

  • Adds a new server option allowAggregationForReadOnlyMasterKey (default true, current behavior). When set to false, the read-only master key cannot run aggregation pipelines via the aggregate endpoint.
  • Deprecates the option so that its default changes to false in the next major version.
  • Expands the readOnlyMasterKey option documentation to clarify that it is a secret key for internal, server-side use only and must never be shipped, distributed, published, or exposed to untrusted parties.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)

@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 19, 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: fd956a9a-f30d-4450-868c-7c12a8f577fb

📥 Commits

Reviewing files that changed from the base of the PR and between 6ed35db and 04d9619.

📒 Files selected for processing (6)
  • spec/ParseQuery.Aggregate.spec.js
  • src/Deprecator/Deprecations.js
  • src/Options/Definitions.js
  • src/Options/docs.js
  • src/Options/index.js
  • src/Routers/AggregateRouter.js

📝 Walkthrough

Walkthrough

Adds a new allowAggregationForReadOnlyMasterKey boolean server option (default true) that controls whether the readOnlyMasterKey can execute aggregation pipelines via the aggregate endpoint. AggregateRouter.handleFind enforces this by throwing OPERATION_FORBIDDEN for read-only requests when the option is falsy. Option definition, JSDoc, and a deprecation entry with changeNewDefault: 'false' are also added.

Changes

allowAggregationForReadOnlyMasterKey option and enforcement

Layer / File(s) Summary
Option definition, type, docs, and deprecation
src/Options/Definitions.js, src/Options/index.js, src/Options/docs.js, src/Deprecator/Deprecations.js
Registers allowAggregationForReadOnlyMasterKey (env: PARSE_SERVER_ALLOW_AGGREGATION_FOR_READ_ONLY_MASTER_KEY, default true) in all option layers; expands readOnlyMasterKey help/doc text; adds a deprecation entry with changeNewDefault: 'false'.
AggregateRouter permission check
src/Routers/AggregateRouter.js
Inserts an early guard in handleFind that throws Parse.Error.OPERATION_FORBIDDEN when req.auth.isReadOnly is true and req.config.allowAggregationForReadOnlyMasterKey is falsy.
Integration tests
spec/ParseQuery.Aggregate.spec.js
Adds four tests covering: default allow for the read-only master key, denial when the option is false, denial of a $out-stage pipeline under the same setting, and continued access for the full master key when the option is false.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was provided by the author, leaving all required template sections (Issue, Approach, Tasks) unfilled. Add a detailed description following the template: include the issue/link, describe the approach and changes, and mark completed tasks like adding tests and documentation updates.
Engage In Review Feedback ❓ Inconclusive Cannot verify review feedback engagement without access to GitHub's PR review API; sandboxed environment lacks tools to query PR comments, review dismissals, or GitHub discussion threads. Access GitHub API or review dashboard at #10517 to verify if review comments exist, were dismissed, or were addressed via commits/discussion.
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required 'feat:' prefix and clearly describes the main change: adding an option to control aggregation pipeline access for the read-only master key.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 PR properly addresses the security risk that aggregation pipelines with $out/$merge stages enable write operations despite using read-only master key. Authorization check correctly placed at start...

✏️ 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.18][ERROR]: Error: exception Unix_error: No such file or directory stat spec/ParseQuery.Aggregate.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.

@codecov

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha   #10517   +/-   ##
=======================================
  Coverage   92.65%   92.65%           
=======================================
  Files         193      193           
  Lines       16969    16971    +2     
  Branches      248      248           
=======================================
+ Hits        15723    15725    +2     
  Misses       1225     1225           
  Partials       21       21           

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

@mtrezza mtrezza merged commit 816078f into parse-community:alpha Jun 19, 2026
24 checks passed
parseplatformorg pushed a commit that referenced this pull request Jun 19, 2026
# [9.10.0-alpha.1](9.9.1-alpha.13...9.10.0-alpha.1) (2026-06-19)

### Features

* Add option to disallow aggregation pipelines for the read-only master key ([#10517](#10517)) ([816078f](816078f))
@mtrezza mtrezza deleted the feat/read-only-master-key-aggregation branch June 19, 2026 23:12
@parseplatformorg

Copy link
Copy Markdown
Contributor

🎉 This change has been released in version 9.10.0-alpha.1

@parseplatformorg parseplatformorg added the state:released-alpha Released as alpha version label Jun 19, 2026
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