[GalaxyRepository] Scoped browse hides the ancestors of an allowed subtree #42

Closed
opened 2026-11-09 14:39:23 -05:00 by dohertj2 · 1 comment
Owner

From the scadaproj#15 shared-library review (code-reviews/GalaxyRepository/findings.md, GalaxyRepository-002), verified at 91fb2b4. Update the finding's Resolution row when fixed.

Severity Medium
Priority P2
Category Correctness & logic bugs
Status Open
Location ZB.MOM.WW.GalaxyRepository/src/ZB.MOM.WW.GalaxyRepository/GalaxyBrowseProjector.cs:134 (also ZB.MOM.WW.GalaxyRepository/src/ZB.MOM.WW.GalaxyRepository/GalaxyHierarchyProjector.cs:233)

Description

GetFilteredChildren runs MatchesBrowseSubtrees(view, globs) first and continues when a direct
child fails it. It never checks whether that child has a descendant that is inside the allowed
subtree.

Right below, the request-filter branch does surface ancestors of matching descendants, with
HasMatchingDescendant and the comment "a matching descendant should still surface its ancestor".
The scope branch has no equivalent.

So with a scope glob like Plant/LineA/*, neither Plant nor Plant/LineA matches. Both are
filtered out of their parent's child list. DiscoverHierarchy likewise omits the Plant/LineA area
object itself.

Failure scenario

An mxaccessgw API key is scoped to BrowseSubtrees: ["Plant/LineA/*"]. A lazy-browse client starts
at the root with BrowseChildren{} and expands nodes, as the OtOpcUa / ScadaBridge browse dialogs
do. Scratch-test result over Plant → LineA → Pump01, Plant → LineB → Pump02:

  • Root BrowseChildren: TotalChildCount = 0.
  • DiscoverHierarchy: only Pump01 (no LineA area).
  • BrowseChildren{ParentContainedPath="Plant/LineA"}: 1 child.

The scoped user sees an empty Galaxy unless they already know and type the exact parent path.

Admins can work around it by also listing the ancestor paths as globs (Plant, Plant/LineA), but
that is undocumented. It also exposes those ancestor objects with their attributes, which is wider
than the intended scope.

Recommendation

In GetFilteredChildren, when a child fails the scope check, test whether it is an ancestor of an
allowed path. Either use HasMatchingDescendant with the scope applied, or do a cheap prefix test of
the child's ContainedPath + "/" against each glob's literal prefix. If it is an ancestor, include
it as a navigation-only node (has_children=true) with its attributes stripped.

Document the semantics on IGalaxyBrowseScopeProvider. Add a test that browses from the root under
a deep scope glob.

Resolution

Unresolved.

From the scadaproj#15 shared-library review (`code-reviews/GalaxyRepository/findings.md`, **GalaxyRepository-002**), verified at 91fb2b4. Update the finding's Resolution row when fixed. | | | |--|--| | Severity | Medium | | Priority | P2 | | Category | Correctness & logic bugs | | Status | Open | | Location | `ZB.MOM.WW.GalaxyRepository/src/ZB.MOM.WW.GalaxyRepository/GalaxyBrowseProjector.cs:134` (also `ZB.MOM.WW.GalaxyRepository/src/ZB.MOM.WW.GalaxyRepository/GalaxyHierarchyProjector.cs:233`) | **Description** `GetFilteredChildren` runs `MatchesBrowseSubtrees(view, globs)` first and `continue`s when a direct child fails it. It never checks whether that child has a descendant that *is* inside the allowed subtree. Right below, the request-filter branch does surface ancestors of matching descendants, with `HasMatchingDescendant` and the comment "a matching descendant should still surface its ancestor". The scope branch has no equivalent. So with a scope glob like `Plant/LineA/*`, neither `Plant` nor `Plant/LineA` matches. Both are filtered out of their parent's child list. `DiscoverHierarchy` likewise omits the `Plant/LineA` area object itself. **Failure scenario** An mxaccessgw API key is scoped to `BrowseSubtrees: ["Plant/LineA/*"]`. A lazy-browse client starts at the root with `BrowseChildren{}` and expands nodes, as the OtOpcUa / ScadaBridge browse dialogs do. Scratch-test result over `Plant → LineA → Pump01`, `Plant → LineB → Pump02`: - Root `BrowseChildren`: `TotalChildCount = 0`. - `DiscoverHierarchy`: only `Pump01` (no `LineA` area). - `BrowseChildren{ParentContainedPath="Plant/LineA"}`: 1 child. The scoped user sees an empty Galaxy unless they already know and type the exact parent path. Admins can work around it by also listing the ancestor paths as globs (`Plant`, `Plant/LineA`), but that is undocumented. It also exposes those ancestor objects *with their attributes*, which is wider than the intended scope. **Recommendation** In `GetFilteredChildren`, when a child fails the scope check, test whether it is an ancestor of an allowed path. Either use `HasMatchingDescendant` with the scope applied, or do a cheap prefix test of the child's `ContainedPath + "/"` against each glob's literal prefix. If it is an ancestor, include it as a navigation-only node (`has_children=true`) with its attributes stripped. Document the semantics on `IGalaxyBrowseScopeProvider`. Add a test that browses from the root under a deep scope glob. **Resolution** _Unresolved._
dohertj2 added the type:review-findingpriority:p2 labels 2026-11-09 14:39:23 -05:00
Author
Owner

Fixed on main 4140509 (GalaxyRepository-002 → Resolved): ancestors of an allowed object appear as navigation-only nodes (attributes stripped, has-children set); only the path to the allowed object is listed, so siblings stay hidden; ancestors appear only when an allowed descendant also passes the request's filters. Consumer behaviour change (mxaccessgw, HistorianGateway): a scoped DiscoverHierarchy now also returns those ancestors, counted by new NavigationAncestorCount; WatchDeployEvents subtracts it so its counts still cover allowed objects only. Rules documented on IGalaxyBrowseScopeProvider. Ships in GalaxyRepository 0.2.1 (unpublished). Evidence: Overview 195/195, Theme 65/65, GalaxyRepository 74/74; each regression test failed before its fix; code-reviews --check consistent.

Fixed on main 4140509 (GalaxyRepository-002 → Resolved): ancestors of an allowed object appear as navigation-only nodes (attributes stripped, has-children set); only the path to the allowed object is listed, so siblings stay hidden; ancestors appear only when an allowed descendant also passes the request's filters. **Consumer behaviour change (mxaccessgw, HistorianGateway):** a scoped DiscoverHierarchy now also returns those ancestors, counted by new NavigationAncestorCount; WatchDeployEvents subtracts it so its counts still cover allowed objects only. Rules documented on IGalaxyBrowseScopeProvider. Ships in GalaxyRepository 0.2.1 (unpublished). Evidence: Overview 195/195, Theme 65/65, GalaxyRepository 74/74; each regression test failed before its fix; code-reviews --check consistent.
Sign in to join this conversation.