[SES-003] AddBufferedItem skips API-key read-constraint check #242
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
SES-003:
AddBufferedItemskips the API-key read-constraint checkGrpc/MxAccessGatewayService.cs:338-483(ApplyConstraintsAsync: cases forAddItemat:347andAddItem2at:351, none forAddBufferedItem)Sessions/GatewaySession.cs:1420-1421,:1535-1541(the session does treatAddBufferedItemas an add elsewhere)Description
Read constraints are enforced when an item is added:
AddItem,AddItem2,AddItemBulk,SubscribeBulkandReadBulkall callCheckReadTagAsync. SingleAdviseis not checked, because it relies on the add having been checked.AddBufferedItemcarries anitem_definitionlike the other adds but falls intodefault: return null, so it reaches the worker unchecked.Failure scenario
A key is restricted to the read subtree
AreaA. It callsAddBufferedItem(server, "AreaB.Tank.Level"), which succeeds, thenAdviseon the returned handle. Data forAreaB.Tank.Levelarrives on its event stream. No denial is audited.Suggested fix
Add an
AddBufferedItemcase that callsEnforceReadTagAsyncwithcommand.AddBufferedItem.ItemDefinition. Consider making the switch fail closed for any command kind that carries a tag address.Test idea
In the
MxAccessGatewayServiceconstraint tests, sendAddBufferedItemfor a tag outside the key's read scope. AssertPermissionDenied, a recorded denial, and that the worker received no command.Source:
code-reviews/2026-12-02-perf-bugs/README.mdandcode-reviews/2026-12-02-perf-bugs/PLAN.md(commitf200bda6on local branchdocs/review-2026-12-02-perf-bugs, not yet pushed). Reviewed at54367e74.Merged to
mainat68043411(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
Invokenow getPermissionDenied.