dbviewer: block cross-db $lookup form in protected-join guard#7692
Merged
Conversation
joinTargetsOf only extracted $lookup.from when it was a string, so the
cross-database object form (from: {db, coll}) bypassed the members/auth_tokens
join check. Extract the collection from both the string and {db, coll} forms.
Also reorder aggregate() to check Array.isArray before pushing the
iDisplayLength $limit. Adds a cross-db regression test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the DB Viewer aggregation “protected join” guard so it also blocks the cross-database object form of join targets (e.g. $lookup.from: {db, coll}), preventing bypasses that could join into redacted collections like members and auth_tokens. It also makes aggregation handling more robust by avoiding mutations on non-array pipelines.
Changes:
- Extend join target extraction to handle both string and
{db, coll}forms for$lookup/$graphLookup/$unionWithvia acollectionOfhelper. - Add a regression unit test covering
$lookupcross-db object form joins intomembers. - Move the
iDisplayLength$limitpush behind anArray.isArraycheck to avoid runtime errors on invalid pipeline types.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
plugins/dbviewer/api/parts/aggregation_guard.js |
Adds collectionOf and uses it to recognize protected join targets in both string and {db, coll} forms. |
plugins/dbviewer/api/api.js |
Prevents pushing $limit onto non-array pipelines by validating the pipeline type before mutation. |
test/unit-tests/plugins.dbviewer.aggregation-guard.js |
Adds regression coverage for $lookup.from cross-db object form joining into members. |
Cookiezaurs
approved these changes
Jun 9, 2026
…s-db test
- non-array aggregation is a client input error -> 400 (was 500), with an
explicit return
- add a regression test for the cross-db {db, coll} form on $graphLookup too
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
ar2rsawseen
added a commit
that referenced
this pull request
Jun 9, 2026
Mirror of the master review fixes (#7692) onto the 24.05 backport. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #7686 (review finding). The DB Viewer protected-collection join guard only recognized the string form of
$lookup.from, so the cross-database object form —{from: {db, coll}}— slipped past the check and could join intomembers/auth_tokens.Fix
joinTargetsOfnow extracts the collection name from both the string and the{db, coll}object forms (via acollectionOfhelper), for$lookup/$graphLookup/$unionWith, so the hard-rule join guard holds regardless of syntax.aggregate()checksArray.isArraybefore pushing theiDisplayLength$limit, so a non-array pipeline returns a controlled error.Tests
Adds a regression test for the
{db, coll}cross-db form (28 guard tests pass).🤖 Generated with Claude Code