fix(federation): honour confidentiality under every name it is stored as - #2438
Conversation
The federated-share visibility filter withholds non-public objects from
non-object-scope shares. It read exactly ONE property name:
$confidentiality = strtolower((string) ($object['confidentiality'] ?? ''));
if (in_array($confidentiality, self::PUBLIC_CONFIDENTIALITY, true) === false)
while the same concept is written under two others:
- `confidentialityLevel` — the target SeedZgwZakenMigrationPack maps
`/vertrouwelijkheidaanduiding` onto;
- `vertrouwelijkheidaanduiding` — the ZGW/GGM schema property itself.
THIS FAILS OPEN, NOT CLOSED. `?? ''` yields the empty string for an object
storing its level under either other name, and `PUBLIC_CONFIDENTIALITY` is
`['', 'openbaar', 'public', 'open']` — the empty string is IN it, because an
object with no level set is public. So an object marked `zeer_geheim` under a
name this guard did not read was served as public over federation.
One concept, three spellings, and the mismatch is silent in both directions:
nothing errors, nothing logs, and a response-shape assertion cannot see it
because the field is absent rather than wrong.
THE FIX reads the first present, non-empty key from an explicit alias list.
"Present AND non-empty", not merely present: a schema sync can add an empty
column before anything writes to it, and an empty `confidentiality` sitting in
front of a populated `confidentialityLevel` would reinstate the same fail-open.
The same alias-reading pattern already guards organisation two lines above.
DIRECTION OF CHANGE. Measured across seven cases, three moved SHARED to
blocked and NONE moved blocked to SHARED. The change can only ever withhold
more, never expose more. Objects with no level set stay public, which is the
intended meaning of the empty string.
VERIFIED
- phpunit: 14 tests, 20 assertions green across the new suite and the
existing FederationControllerScopeTest, on PHP 8.3 (this app's floor; the
host runs 8.2 and composer's platform check refuses it).
- Positive control: reverting the guard to the single-key read turns the new
suite RED at 4 of 8 — the four leaking rows — and restoring it returns 8/8.
A first attempt at this control silently did not apply the revert and
re-tested the fixed code twice; the run above is the one that actually
flipped the source.
- phpcs: 0 errors on both files. FederationController carries 7 warnings both
before and after this change.
The related finding is NOT addressed here: ZaaktypeAuthorizationService — the
ZGW authorization mapper that owns confidentiality ordinal ordering and
buildConfidentialityMatch() — has zero call sites in lib/. All seven of its
public methods are exercised only by their own unit test, while the archived
change 2026-06-14-rbac-zaaktype marks those tasks complete and describes the
service as the enforcement path. That needs its own investigation.
Quality Report — ConductionNL/openregister @
|
| Check | PHP | Vue | Security | License | Tests |
|---|---|---|---|---|---|
| lint | ✅ | ||||
| phpcs | ❌ | ||||
| phpmd | ❌ | ||||
| psalm | ✅ | ||||
| phpstan | ✅ | ||||
| phpmetrics | ✅ | ||||
| eslint | ✅ | ||||
| stylelint | ✅ | ||||
| build | ✅ | ||||
| check-specs | ✅ | ||||
| test-l10n | ✅ | ||||
| composer | ✅ | ✅ 173/173 | |||
| npm | ✅ | ✅ 546/546 | |||
| PHPUnit | ❌ | ||||
| Newman | ✅ | ||||
| Playwright | ✅ | ||||
| Hydra gates | ❌ |
Quality workflow — 2026-08-12 07:48 UTC
Download the full PDF report from the workflow artifacts.
The seven red checks are pre-existing — measured, not assumed
PHPUnit is the one worth showing, because it is the check most likely to be mine:
The delta is exactly +8 tests — the 8 this PR adds — and the same single pre-existing failure. Nothing here broke it and nothing here fixes it. The seventh, That trap is worth naming: comparing a PR-only job (or a similarly-named different job) against a branch that never runs it makes a pre-existing failure look new. It is the same shape as What this PR containsThe federation confidentiality alias read and its 8-test regression suite. phpcs measured 0 errors on both changed files locally, against a 7-warning baseline that is unchanged. |
Two independent reds on `development`, neither of them a defect in shipped behaviour, both of them a test/spec artefact that CI is right to refuse. 1. PHPUnit (PHP 8.3 and 8.4, NC stable32) — ONE failing test out of 16306. a5b8dc2 ("a mapping you just created was invisible to every read") deliberately made MapNode::resolve() ask find() FIRST for a non-numeric reference, because find() is the only lookup that consults the uuid and slug columns. MapNodeTest::testANonNumericReferenceResolvesByRef still pinned the OLD order with `expects($this->never())->method('find')`, so the fix and its own suite disagreed: Expectation failed for method name is "find" when invoked 0 times. Method was expected to be called 0 times, actually called 1 time. The test's intent — a name living in the `reference` column alone still resolves — is unchanged and worth keeping. It now reaches findByRef() the way production does: through find() MISSING. That fall-through is the part that actually carries an exported flow, so making find() throw is a stronger test than making it unreachable. testAUuidReferenceResolvesThroughFind is added because nothing pinned the new order at all. Its `never()` on findByRef() is the assertion: a resolve() that went back to consulting the `reference` column first would satisfy every other test in the file. POSITIVE CONTROL. At the tree before this commit the suite is 8 tests, 1 failure — the exact CI message. With this commit, 9/9 green. Deleting the find()-first block from MapNode::resolve() again turns it into 1 failure + 1 error, on exactly these two tests, with the predicted text ("expected 1 time, actually 0" and RuntimeException "No mapping matches ..."). MapNode.php is restored byte-identical; it is NOT touched here. 2. Hydra Gates — [gate-46] spec-anchor-existence, 3 findings, 1 target. #2438 tagged three methods `@spec openspec/specs/federation/spec.md`. That file did not exist: federation's only written specs live in openspec/changes/federation-scope-enforcement and openspec/changes/federated-config-sharing, and a change directory is not a canonical target. The gate says "fix the TARGET, not each tag", so the canonical spec is written rather than the tags retargeted. Its content is read off the code it describes — CONFIDENTIALITY_KEYS, PUBLIC_CONFIDENTIALITY and applyShareVisibility() — and its scenarios are the seven data-provider cases that already exist in FederationControllerConfidentialityTest plus the object-scope bypass. Nothing is invented. The two requirements carry a reason-bearing `@e2e exclude` naming that test file. Without it this commit would have traded gate-46 for gate-19: measured, the spec's 7 new scenarios fail gate-19 as "missing @e2e" and pass with the excludes. POSITIVE CONTROL. check_spec_anchors.py against the two tagged files reports exactly the 3 CI findings when the spec is moved aside and 0 when it is present. check_e2e_coverage.py reports FAIL 7 without the exclusions and PASS with them. check_spec_coverage.py (gate-16) is 0 either way — nothing here is in its scope. NOT FIXED HERE, and deliberately so: phpmd's 6 findings are all in lib/Service/Flow (FlowRunAdvancer:83, FlowService:55/78/480, IterateNode:238, ObjectWriteNode:1445), which is another session's live work under #2429. phpcs's two errors were fixed by that session in 61c9f38/9c05a3f44 while this was in progress — verified here, full-tree phpcs is 0 errors on 1428 files at that base. Quality Report is a pure aggregator and carries no finding of its own.
A confidentiality guard that fails open on a property-name mismatch
FederationController::applyShareVisibility()withholds non-public objects from non-object-scope federated shares. It read exactly one property name:The same concept is written under two others:
confidentialityconfidentialityLevelSeedZgwZakenMigrationPackmaps/vertrouwelijkheidaanduidingonto itvertrouwelijkheidaanduidingThis fails open, not closed.
?? ''yields the empty string for an object storing its level under either other name, andPUBLIC_CONFIDENTIALITYis['', 'openbaar', 'public', 'open']— the empty string is in the allowlist, because an object with no level set is public. So an object markedzeer_geheimunder a name the guard didn't read was served as public.The mismatch is silent in both directions: nothing errors, nothing logs, and a response-shape assertion can't catch it because the field is absent rather than wrong.
The fix
Read the first present, non-empty key from an explicit alias list. Present and non-empty, not merely present — a schema sync can add an empty column before anything writes to it, and an empty
confidentialityin front of a populatedconfidentialityLevelwould reinstate the same fail-open.The alias-reading pattern isn't new here: the organisation guard two lines above already does
$self['organisation'] ?? $object['organisation'].Direction of change
Measured across seven cases:
zeer_geheimvertrouwelijkzeer_geheimopenbaarThree moved SHARED → blocked; none moved blocked → SHARED. The change can only withhold more, never expose more. Objects with no level set stay public, which is what the empty string is there to mean.
Verification
FederationControllerScopeTest, on PHP 8.3 — this app's floor; the host runs 8.2 and composer's platform check refuses it, so a local run would have been no evidence.A first attempt at that control silently failed to apply the revert and re-tested the fixed code twice, reporting green both times. The run quoted above is the one that actually flipped the source.
FederationControllercarries 7 warnings both before and after.Scope I did not close
SeedZgwZakenMigrationPack's own docblock calls it "a worked example (not a ready-to-run pack)", so it may never have run as-is. The schema propertyvertrouwelijkheidaanduidingis real regardless.object.The fix is worth landing on its own merits either way: reading one of three names for a security decision is wrong whether or not it is currently being exploited.
Related finding, not addressed here
ZaaktypeAuthorizationService— the ZGW authorization mapper that owns confidentiality ordinal ordering andbuildConfidentialityMatch()— has zero call sites inlib/. All seven public methods are exercised only by their own unit test, while the archived change2026-06-14-rbac-zaaktypemarks those tasks[x]and describes the service as the enforcement path. A fully-tested authorization service with no callers is indistinguishable from no check at all. That needs its own investigation and I have not done it.