[DSH-001] Dashboard /alarms AlarmsPolicy bypassed by in-circuit navigation (plain RouteView) #243

Closed
opened 2026-12-02 16:07:33 -05:00 by dohertj2 · 2 comments
Owner

DSH-001 — /alarms AlarmsPolicy is bypassed by in-circuit navigation

  • Severity: High — Category: Bug (security) — Confidence: Confirmed (code reading; not exercised in a browser)
  • Locations:
    • Dashboard/Components/Routes.razor:4 — <RouteView ...>, not AuthorizeRouteView
    • Dashboard/Components/App.razor:13 — <Routes @rendermode="InteractiveServer" /> (global interactive routing)
    • Dashboard/Components/Pages/AlarmsPage.razor:12 — [Authorize(Policy = AlarmsPolicy)] is the only gate; OnInitialized (212–216) starts the poll and feed loops unconditionally
    • Dashboard/DashboardEndpointRouteBuilderExtensions.cs:135-138 — endpoint-level RequireAuthorization(ViewerPolicy)
    • src/ZB.MOM.WW.MxGateway.Tests/Gateway/Dashboard/AlarmFeedAuthorizationTests.cs:144-159 — asserts endpoint metadata only

Description. The page attribute is enforced by endpoint routing on a full HTTP request to /alarms. With the router rendered interactively, a navigation that starts inside an existing circuit never issues an HTTP request for the page: the in-circuit Router resolves the route and RouteView renders it. RouteView does not evaluate [Authorize]; only AuthorizeRouteView does. AlarmsPage has no in-component check, and IDashboardLiveDataService.QueryAlarmsAsync / IGatewayAlarmService.StreamAsync take no principal.

Failure scenario. Anonymous localhost (AllowAnonymousLocalhost=true, the default) or any caller under Authentication:Mode=Disabled loads / — allowed by ViewerPolicy. The nav link is hidden (MainLayout.razor:18-22), but the caller runs Blazor.navigateTo('/alarms') in the console, or clicks any in-page anchor pointing at /alarms. The circuit renders AlarmsPage and the galaxy-wide alarm list is displayed. This is exactly the audience the contract says "do not receive it at all".

Related. /admin/secrets (shared ZB.MOM.WW.Secrets.Ui page) relies on the same attribute mechanism, so a Viewer can reach it the same way. Its mutating and reveal controls are separately wrapped in AuthorizeView in the library source, so the exposure there appears limited to the list itself. Not verified against the packaged 1.0.1 build.

Suggested fix. Switch Routes.razor to AuthorizeRouteView with a NotAuthorized fragment. Check that anonymous localhost still passes ViewerPolicy in-circuit, since DashboardAuthorizationHandler reads IHttpContextAccessor. As defense in depth, have AlarmsPage call IAuthorizationService.AuthorizeAsync(user, AlarmsPolicy) before starting its loops.

Test idea. bUnit: render Routes with an unauthenticated AuthenticationState, navigate the NavigationManager to /alarms, assert AlarmsPage is not instantiated and IGatewayAlarmService.StreamAsync is never called.


Source: code-reviews/2026-12-02-perf-bugs/README.md and code-reviews/2026-12-02-perf-bugs/PLAN.md (commit f200bda6 on local branch docs/review-2026-12-02-perf-bugs, not yet pushed). Reviewed at 54367e74.

## DSH-001 — `/alarms` `AlarmsPolicy` is bypassed by in-circuit navigation - **Severity:** High — **Category:** Bug (security) — **Confidence:** Confirmed (code reading; not exercised in a browser) - **Locations:** - `Dashboard/Components/Routes.razor:4` — `<RouteView ...>`, not `AuthorizeRouteView` - `Dashboard/Components/App.razor:13` — `<Routes @rendermode="InteractiveServer" />` (global interactive routing) - `Dashboard/Components/Pages/AlarmsPage.razor:12` — `[Authorize(Policy = AlarmsPolicy)]` is the only gate; `OnInitialized` (212–216) starts the poll and feed loops unconditionally - `Dashboard/DashboardEndpointRouteBuilderExtensions.cs:135-138` — endpoint-level `RequireAuthorization(ViewerPolicy)` - `src/ZB.MOM.WW.MxGateway.Tests/Gateway/Dashboard/AlarmFeedAuthorizationTests.cs:144-159` — asserts endpoint metadata only **Description.** The page attribute is enforced by endpoint routing on a full HTTP request to `/alarms`. With the router rendered interactively, a navigation that starts inside an existing circuit never issues an HTTP request for the page: the in-circuit `Router` resolves the route and `RouteView` renders it. `RouteView` does not evaluate `[Authorize]`; only `AuthorizeRouteView` does. `AlarmsPage` has no in-component check, and `IDashboardLiveDataService.QueryAlarmsAsync` / `IGatewayAlarmService.StreamAsync` take no principal. **Failure scenario.** Anonymous localhost (`AllowAnonymousLocalhost=true`, the default) or any caller under `Authentication:Mode=Disabled` loads `/` — allowed by `ViewerPolicy`. The nav link is hidden (`MainLayout.razor:18-22`), but the caller runs `Blazor.navigateTo('/alarms')` in the console, or clicks any in-page anchor pointing at `/alarms`. The circuit renders `AlarmsPage` and the galaxy-wide alarm list is displayed. This is exactly the audience the contract says "do not receive it at all". **Related.** `/admin/secrets` (shared `ZB.MOM.WW.Secrets.Ui` page) relies on the same attribute mechanism, so a Viewer can reach it the same way. Its mutating and reveal controls are separately wrapped in `AuthorizeView` in the library source, so the exposure there appears limited to the list itself. Not verified against the packaged 1.0.1 build. **Suggested fix.** Switch `Routes.razor` to `AuthorizeRouteView` with a `NotAuthorized` fragment. Check that anonymous localhost still passes `ViewerPolicy` in-circuit, since `DashboardAuthorizationHandler` reads `IHttpContextAccessor`. As defense in depth, have `AlarmsPage` call `IAuthorizationService.AuthorizeAsync(user, AlarmsPolicy)` before starting its loops. **Test idea.** bUnit: render `Routes` with an unauthenticated `AuthenticationState`, navigate the `NavigationManager` to `/alarms`, assert `AlarmsPage` is not instantiated and `IGatewayAlarmService.StreamAsync` is never called. --- Source: `code-reviews/2026-12-02-perf-bugs/README.md` and `code-reviews/2026-12-02-perf-bugs/PLAN.md` (commit `f200bda6` on local branch `docs/review-2026-12-02-perf-bugs`, not yet pushed). Reviewed at `54367e74`.
dohertj2 added the area:dashboardarea:authpriority:p0type:bugtype:review-finding labels 2026-12-02 16:07:33 -05:00
Author
Owner

Decision (2026-12-03, recorded as D3 in code-reviews/2026-12-02-perf-bugs/PLAN.md): the AuthorizeRouteView fix must also be verified for /admin/secrets (Secrets.Ui) with a test: a Viewer navigating in-circuit gets NotAuthorized. If it was reachable before the fix, record that here as a confirmed exposure.

Decision (2026-12-03, recorded as D3 in `code-reviews/2026-12-02-perf-bugs/PLAN.md`): the `AuthorizeRouteView` fix must also be verified for `/admin/secrets` (Secrets.Ui) with a test: a Viewer navigating in-circuit gets NotAuthorized. If it was reachable before the fix, record that here as a confirmed exposure.
Author
Owner

Merged to main at 68043411 (pushed 2026-12-03). Gateway suite 1610 passed / 0 failed (macOS); windev worker CI 836 passed / 0 failed on that SHA.

D3 result — confirmed exposure. A test run against the old Routes.razor showed a Viewer could reach /admin/secrets by in-circuit navigation (secret names, descriptions, KEK id, revision, updated-by; reveal/edit stayed hidden), and anonymous localhost could reach /alarms the same way. Both now get NotAuthorized via AuthorizeRouteView (DashboardRouteAuthorizationTests). The test uses a stand-in for the Secrets page because the real page stack-overflowed under the test renderer — unverified whether that affects the live page.

Merged to `main` at `68043411` (pushed 2026-12-03). Gateway suite 1610 passed / 0 failed (macOS); windev worker CI 836 passed / 0 failed on that SHA. **D3 result — confirmed exposure.** A test run against the old `Routes.razor` showed a Viewer could reach `/admin/secrets` by in-circuit navigation (secret names, descriptions, KEK id, revision, updated-by; reveal/edit stayed hidden), and anonymous localhost could reach `/alarms` the same way. Both now get NotAuthorized via `AuthorizeRouteView` (`DashboardRouteAuthorizationTests`). The test uses a stand-in for the Secrets page because the real page stack-overflowed under the test renderer — unverified whether that affects the live page.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/mxaccessgw#243