fix(dbal): resolve object-source Source refs as system lookup — tenant filter emptied cross-org registers (fixes #2089)#2090
Open
rubenvdlinde wants to merge 1 commit into
Conversation
…t filter emptied cross-org registers (fixes #2089) DbalObjectSourceProvider::resolveSource() loaded the backing Source via SourceMapper::find()/findAll(), both organisation-filtered. A Source is shared infrastructure config, not tenant-owned data — the schema's own read RBAC is already enforced by ObjectService::paginateObjectSource() before the provider ever runs, so filtering the Source row by the caller's active organisation added no isolation while breaking any dbal-backed schema whose Source lives in a different organisation, most visibly under saasMode:true where admin override is unconditionally disabled. Adds SourceMapper::findForSystem() — an id/uuid lookup with no RBAC verification and no organisation filter, mirroring the existing findBySyncEnabled() system-actor pattern — and wires resolveSource() to use it. Ordinary SourceMapper callers (admin CRUD/listing) are untouched. Adds openspec change dbal-source-resolution-system-context with the requirement + rationale, and a regression test asserting resolution goes through the unfiltered system lookup (never find()/findAll()) and still returns objects for a cross-organisation Source.
Contributor
Quality Report — ConductionNL/openregister @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ✅ | ||||
| phpmd | ✅ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| composer | ❌ | ✅ 174/174 | |||
| npm | ✅ | ✅ 555/555 | |||
| PHPUnit | ⏭️ | ||||
| Newman | ⏭️ | ||||
| Playwright | ⏭️ |
Quality workflow — 2026-07-24 21:19 UTC
Download the full PDF report from the workflow artifacts.
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.
Summary
Fixes #2089 (follow-up to #2084 / PR #2088).
DbalObjectSourceProvider::resolveSource()loaded the backingSourcevia organisation-filteredSourceMapper::find()/findAll(). ASourceis shared infrastructure config (an external DB connection), not tenant-owned data — the schema's own read RBAC is already enforced byObjectService::paginateObjectSource()(checkPermission()) before the provider ever runs. Filtering the Source row by the caller's active organisation added no additional isolation while breaking every dbal-backed schema whose Source lives in a different organisation, most visibly undersaasMode: truewhere admin override is unconditionally disabled —resolveSource()returnednull, and every downstreamfind/findAll/count/aggregatesilently returned empty (logged only as awarning).Design
SourceMapper::findForSystem(string $sourceId): ?Source— an id/uuid lookup with no RBAC verification and no organisation filter, mirroring the mapper's existingfindBySyncEnabled()system-actor pattern (same file, same rationale: system-initiated lookup, no tenant scoping). Docblock states the security rationale explicitly and the constraint that it must never be exposed to a caller that hasn't already authorized at the schema/object level.DbalObjectSourceProvider::resolveSource()now callsfindForSystem()instead offind()/findAll().SourceMappercallers (Sources admin CRUD/listing) are untouched — default organisation filtering is not weakened for any other caller.dbal-source-resolution-system-context(proposal + tasks + spec delta) with@spectags on both changed methods.Tests
testResolveSourceUsesSystemLookupAcrossOrganisationsinDbalObjectSourceProviderTest: a Source in a different organisation still resolves and serves objects, and assertsfind()/findAll()are never called (onlyfindForSystem()) — proving the fix path.PaginateObjectSourceTest::testDeniedReadRejectsBeforeProviderIsConsulted(untouched) continues to cover REQ-DSRSC-002 — schema-level RBAC still gates before the provider runs.php -l,composer phpcs(clean),phpstan(clean — also fixed a pre-existing phpstan-only warning on an unrelated method encountered while scoping the file) on both changed lib files.DbalObjectSourceProviderTest(20/20) andPaginateObjectSourceTest(8/8) green in thenextcloud:34.0.0-apachecontainer.Test plan
nextcloud:34.0.0-apache)saasMode: true(tracked in DbalObjectSourceProvider silently returns empty when the shared Source's organisation differs from the caller's active org (SaaS mode) #2089/MultiTenancyTrait::applyActiveOrgFilter() calls orX() with zero args — fatal on NC34, breaks ALL dbal-source query-backed schemas #2084, done post-merge)