[SES-003] AddBufferedItem skips API-key read-constraint check #242

Closed
opened 2026-12-02 16:07:32 -05:00 by dohertj2 · 1 comment
Owner

SES-003: AddBufferedItem skips the API-key read-constraint check

  • Severity: High
  • Category: Bug (authorization)
  • Confidence: Confirmed
  • Locations:
    • Grpc/MxAccessGatewayService.cs:338-483 (ApplyConstraintsAsync: cases for AddItem at :347 and AddItem2 at :351, none for AddBufferedItem)
    • Sessions/GatewaySession.cs:1420-1421, :1535-1541 (the session does treat AddBufferedItem as an add elsewhere)

Description

Read constraints are enforced when an item is added: AddItem, AddItem2, AddItemBulk, SubscribeBulk and ReadBulk all call CheckReadTagAsync. Single Advise is not checked, because it relies on the add having been checked. AddBufferedItem carries an item_definition like the other adds but falls into default: return null, so it reaches the worker unchecked.

Failure scenario

A key is restricted to the read subtree AreaA. It calls AddBufferedItem(server, "AreaB.Tank.Level"), which succeeds, then Advise on the returned handle. Data for AreaB.Tank.Level arrives on its event stream. No denial is audited.

Suggested fix

Add an AddBufferedItem case that calls EnforceReadTagAsync with command.AddBufferedItem.ItemDefinition. Consider making the switch fail closed for any command kind that carries a tag address.

Test idea

In the MxAccessGatewayService constraint tests, send AddBufferedItem for a tag outside the key's read scope. Assert PermissionDenied, a recorded denial, and that the worker received no command.


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.

## SES-003: `AddBufferedItem` skips the API-key read-constraint check - **Severity:** High - **Category:** Bug (authorization) - **Confidence:** Confirmed - **Locations:** - `Grpc/MxAccessGatewayService.cs:338-483` (`ApplyConstraintsAsync`: cases for `AddItem` at `:347` and `AddItem2` at `:351`, none for `AddBufferedItem`) - `Sessions/GatewaySession.cs:1420-1421`, `:1535-1541` (the session does treat `AddBufferedItem` as an add elsewhere) ### Description Read constraints are enforced when an item is added: `AddItem`, `AddItem2`, `AddItemBulk`, `SubscribeBulk` and `ReadBulk` all call `CheckReadTagAsync`. Single `Advise` is not checked, because it relies on the add having been checked. `AddBufferedItem` carries an `item_definition` like the other adds but falls into `default: return null`, so it reaches the worker unchecked. ### Failure scenario A key is restricted to the read subtree `AreaA`. It calls `AddBufferedItem(server, "AreaB.Tank.Level")`, which succeeds, then `Advise` on the returned handle. Data for `AreaB.Tank.Level` arrives on its event stream. No denial is audited. ### Suggested fix Add an `AddBufferedItem` case that calls `EnforceReadTagAsync` with `command.AddBufferedItem.ItemDefinition`. Consider making the switch fail closed for any command kind that carries a tag address. ### Test idea In the `MxAccessGatewayService` constraint tests, send `AddBufferedItem` for a tag outside the key's read scope. Assert `PermissionDenied`, a recorded denial, and that the worker received no command. --- 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:gatewayarea:authpriority:p0type:bugtype:review-finding labels 2026-12-02 16:07:32 -05:00
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.

Plus a fail-closed command-kind switch with an enum-coverage test. Note: gateway-internal alarm command kinds sent via public Invoke now get PermissionDenied.

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. Plus a fail-closed command-kind switch with an enum-coverage test. Note: gateway-internal alarm command kinds sent via public `Invoke` now get `PermissionDenied`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/mxaccessgw#242