fix(grpc): owner-scope Invoke and CloseSession like StreamEvents (SES-002, #241)

A foreign API key holding the matching scope could Invoke(DrainEvents) another
key's session (dequeuing its events), write through it, or close it. Invoke and
CloseSession now apply the same ordinal owner compare as the StreamEvents
attach and return PermissionDenied. No admin override (D2): operators use the
dashboard, which calls ISessionManager directly.
This commit is contained in:
Joseph Doherty
2026-12-03 09:40:41 -05:00
parent d12fd4f5a0
commit cf00f6fc86
7 changed files with 229 additions and 5 deletions
+15 -1
View File
@@ -94,7 +94,21 @@ the caller's key id matches the owner. Gating on the `events:read` scope alone w
rejected: it would let any `events:read`-scoped key that learned a session id
attach to another key's retained session and receive its replayed and live data. The check
runs before any subscriber is attached, so a foreign key never touches the
replay ring. Admin-scope override is deferred.
replay ring.
Decision (2026-12-03, SES-002 / #241): the owner rule covers every
session-scoped RPC, not just the stream. `Invoke` (every command kind) and
`CloseSession` apply the same ordinal compare as `StreamEvents` and return
`PermissionDenied` to a foreign key before the session manager is reached.
Owner-scoping only the stream left `Invoke(DrainEvents)` — which needs only
`events:read` and dequeues from the same worker queue the event pump drains — as
a way to read another key's events, and let a foreign key write through, or
close, a session it did not open. There is **no admin override**: an
`admin`-scoped key is refused like any other foreign key. Operators close or
kill any session from the dashboard, which calls `ISessionManager` directly and
does not pass through the gRPC owner check; a gRPC override would be a separate,
explicit, audited feature. Internal callers (the alarm monitor, the dashboard)
use `ISessionManager` directly and are unaffected.
## Event Subscribers