Repository navigation
Conversation
… the identity refusal ROUTER_DEVICE_IDENTITY_ALLOW lists entries app|agent_id|user_id|user_name. A device of that app passes the identity refusal of createSession and the socket start frame only when its session keeps its conversation and every identity field it sends equals the entry's. Unset, nothing changes. Remove it once getstream.io#1264 is live. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kanat
left a comment
There was a problem hiding this comment.
VERDICT: NO-GO
[security R1] head 5825f76 (on current main).
- [Blocker] S1.1
device_identity_allow.go:69: the allowance puts one shared agent id on many devices' sessions, and code that looks a running session up by agent id can then act on another user's session. Details and the attack test are in the private ticket. Fix: keep sessions admitted through the list out of lookups by agent id (they keep their conversation in a channel of their own), or an explicit, recorded risk acceptance for this temporary flag. - [Nit] S1.2
device_identity_allow.go:59: the exception also covers voice sessions; the intended use is a text widget.
Checked and fine: which app a request is of comes from the API key and its token (api_key mode) or the gateway's header (proxy mode), and a direct-port caller is already a backend on base, so the list adds nothing there; each sent field must equal one entry, byte for byte, else the #2393 errors; fields of two entries are refused; incognito is refused; reserved ids and the other device-refused fields are still refused; two devices with the listed identity cannot read, list or carry on each other's sessions (probed for signed-in, guest and anonymous); the error and the start log never carry the value; no migration, and an older build ignores the setting (fails closed). Mutations: 8 of the new guards checked, 0 survived. PostureSuite, SessionOwnershipSuite, auth and config pass.
| agent, user, name := value(request.AgentId), value(request.UserId), value(request.UserName) | ||
| if (agent == "" || agent == entry.AgentID) && | ||
| (user == "" || user == session.DefaultUserID || namesOwnUser(ctx, user) || user == entry.UserID) && | ||
| (name == "" || name == session.DefaultUserName || name == entry.UserName) { |
There was a problem hiding this comment.
[Blocker] S1.1 Every device of the listed app may now hold the same agent id on a session that keeps its conversation. Lookups that find a running session by agent id then reach whichever of those sessions is newest, whoever opened it, which lets one user's activity act on another user's session. On base a device cannot pick this id (403). Fix: mark a session whose identity this list let through and leave it out of lookups by agent id, since its conversation lives in its own channel; add a test that another user's activity leaves the first session untouched. The ready test is in the private ticket.
There was a problem hiding this comment.
Fixed in 32ab8de: a session the list let through is marked Spec.ListedIdentity (set in createSession from the refusal without the list, never by a request); Manager.ByAgentWhere skips it and Directory.Hold claims no agent for it. Tests: ChatEpisodesSuite/TestAMessageInTheListedAgentsChannelLeavesADevicesSessionAlone, .../TestAMessageInTheListedAgentsChannelIsHandedOutWhileADevicesSessionRuns, .../TestADevicesSessionWithTheListedAgentIDClaimsNoAgentInTheDirectory (all three fail on 5825f76).
| // request sends that refuseDeviceAgentIdentity would refuse equals the entry's. | ||
| func (a DeviceIdentityAllow) lets(ctx context.Context, request CreateSessionRequest) bool { | ||
| app, _ := CustomerFrom(ctx) | ||
| if value(request.Incognito) { |
There was a problem hiding this comment.
[Nit] S1.2 This also lets the identity through for a voice session (start_voice): the agent then joins the device's call as the listed user_id. That is the identity the operator listed, but the intended use is a text widget. Suggest if value(request.Incognito) || value(request.StartVoice) { return false } plus a unit case, or say in the README row that voice is included.
There was a problem hiding this comment.
Fixed in d9463f4: text only. lets refuses start_voice, and the socket start frame (always voice) passes no list, so it refuses as before. Tests: TestAnAllowedIdentityPassesOnlyForItsAppAndEveryFieldExactly/start_voice, SocketSessionSuite/TestAnIdentityNotListedForTheDeviceIsStillRefused/start_voice/*, SocketSessionSuite/TestADeviceMayHandOverAnIdentityTheOperatorListedForItsApp (socket refused).
kanat
left a comment
There was a problem hiding this comment.
VERDICT: NO-GO
Reviewed 5825f76 (current main 51578aa is its parent). Two Should fix items, both test gaps with ready test rows; the code itself reads right.
Checked and sound:
- Unset or empty setting: head equals base. A differential probe ran base's
refuseDeviceAgentIdentityagainst head with a nil and an empty list over 82,320 combinations (server-side, kind, caller, app, agent/user/name values, incognito). Every result was equal. The #2393 tests (unit,SocketSessionSuite,SlackChannelSuite) only gained thenilargument, and they pass on head for both HTTP and the socket. appisprincipal.AppID: the gateway'sX-Stream-App-Idin proxy mode, the key's app in api_key mode. A caller on a direct router port could also sendStream-Auth-Type: serverand skip the refusal entirely, so the list adds no new way in.- All three call sites pass the list (
createSession, the socket start frame, the innerrefuseDeviceAgentIdentity). Mutants of each are killed. - I ran
run()with the setting in proxy mode. The listed app passed the identity refusal. Another app got the #2393 403. The log saidentries=1and held no values. - Unit and integration suites (
SocketSessionSuite,SlackChannelSuite) pass. The new socket tests pass under-race. Generated files match their source. CI: draft, sogoandintegrationare skipped and run at ready.
Mutations: 29 checked, 5 survived (R1.1: 4, R1.2: 1).
[Question] R1.3 (ticket, not blocking): voice passes too. The socket start frame is always voice (socketws.go:178), and createSession with start_voice is not excluded either. This matches the ticket, which asks for the socket alike. The agent's Stream token is minted on the router and is not returned to the device. If the docs widget is text-only, narrowing the exception to text sessions is Kanat's decision.
|
|
||
| // TEMPORARY (AI-3959): a value that does not read is refused at start rather than ignored, | ||
| // since ignoring it would bring the refusal back for the device it was set for. | ||
| deviceIdentityAllow, err := api.ParseDeviceIdentityAllow(settings.DeviceIdentityAllow) |
There was a problem hiding this comment.
[Should fix] R1.1 No test covers the start-time refusal, the count-only Warn log or the DeviceIdentityAllow: deviceIdentityAllow wiring (line 1568). These four mutants all survive go test ./cmd/router ./internal/api ./internal/config:
- ignore the parse error;
- drop the log;
- log the values;
- pass
nilto Options.
run() needs no database: ChatInboundStartupSuite (cmd/router/chatinbound_test.go) already starts it that way. Add two tests there:
- Setting
x-secret|x-secret:runreturns an error that containsROUTER_DEVICE_IDENTITY_ALLOWand notx-secret. - Proxy mode, setting
app-9|agent-secret|user-secret|Name Secret, a text logger:- The log has
entries=1and none of the three values. POST /v1/agents/sessionswithX-Stream-App-Id: app-9,Stream-Auth-Type: anonymousand the three fields is not theagent_id is sent server-side403. On head it is a later 400not_configured.- The same request for
app-8is the 403.
- The log has
I checked that both tests pass on head and that each mutant fails one of them.
There was a problem hiding this comment.
Fixed in 3de09a1: ChatInboundStartupSuite/TestADeviceIdentityAllowThatDoesNotReadStopsTheRouter (kills M24) and ChatInboundStartupSuite/TestTheDeviceIdentityAllowIsLoggedByCountAndServed (kills M25, M26, M27).
| } | ||
| var allow DeviceIdentityAllow | ||
| for i, entry := range strings.Split(setting, ";") { | ||
| fields := strings.Split(strings.TrimSpace(entry), "|") |
There was a problem hiding this comment.
[Should fix] R1.2 No test pins the per-entry strings.TrimSpace(entry): the mutant strings.Split(entry, "|") survives. An operator value with a space or a newline after ; would then read the app as " app-2". That entry never matches, and the widget's 403s come back. Add this row to the good map of TestDeviceIdentityAllowReadsEachEntryExactly:
"space after a separator": {"app-1|a|u|n;\n app-2|b|v|m", DeviceIdentityAllow{{"app-1", "a", "u", "n"}, {"app-2", "b", "v", "m"}}},It passes on head and fails under the mutant.
There was a problem hiding this comment.
Fixed in a37a250: TestDeviceIdentityAllowReadsEachEntryExactly/space_after_a_separator (fails under M12).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Closing: this temporary allowlist was only needed until getstream.io#1264 reached the prod site. It is live since 2026-11-25 23:59 UTC, and the docs widget no longer sends agent_id, user_id or user_name. The lasting fix is #2490 (AI-3900). |
Why
The router prod release carries #2393, which refuses a browser client that sends
agent_id,user_idoruser_name(refuseDeviceAgentIdentity). A docs chat widget still sends them until GetStream/getstream.io#1264 is live on the prod site, so releasing now brings back its 403s (AI-3893).This is a temporary and narrow exception: one env setting, set by an operator, that names the exact identity a device of one app may send. It is for text sessions only, and the sessions it lets through are not reached by Chat hooks. It is removed once getstream.io#1264 is live; AI-3900 (#2490) is the lasting fix. Unset or empty: no change.
How it works
appis the Stream app id (what the gateway sends asX-Stream-App-Idand the dashboard shows). An emptyuser_idoruser_namein an entry means the device may not send that field. The defaultuser_id/user_nameand a verified caller's own user id stay allowed as before. The router logs the number of entries at start, never the values.Tests
;); bad shapes refuse start without echoing the valueTestDeviceIdentityAllowReadsEachEntryExactlyTestAnAllowedIdentityPassesOnlyForItsAppAndEveryFieldExactlySocketSessionSuite/TestADeviceMayHandOverAnIdentityTheOperatorListedForItsAppSocketSessionSuite/TestAnIdentityNotListedForTheDeviceIsStillRefusedOptions.DeviceIdentityAllowreaches the serverSocketSessionSuite/TestARouterStartedWithTheListLetsTheDeviceThroughagent:<listed id>does not retire the listed sessionChatEpisodesSuite/TestAMessageInTheListedAgentsChannelLeavesADevicesSessionAloneChatEpisodesSuite/TestAMessageInTheListedAgentsChannelIsHandedOutWhileADevicesSessionRunsChatEpisodesSuite/TestADevicesSessionWithTheListedAgentIDClaimsNoAgentInTheDirectoryrunnaming the setting, not the valueChatInboundStartupSuite/TestADeviceIdentityAllowThatDoesNotReadStopsTheRouterrunlogs the entry count, no values, and passes the list to the serverChatInboundStartupSuite/TestTheDeviceIdentityAllowIsLoggedByCountAndServede75990b7b)SocketSessionSuite/TestWithoutTheSettingADeviceIsRefusedAsBeforeConfigSuite/TestTheDeviceIdentityAllowIsOneStringAndNothingByDefaultNo API, spec, migration or SDK change. Documented in
acceleration/README.mdnext to the otherROUTER_*settings, marked TEMPORARY.Removal
Delete
acceleration/internal/api/device_identity_allow.go, its tests, theallowparameter ofrefuseSessionRequestandrefuseDeviceAgentIdentity,Spec.ListedIdentityand its two uses ininternal/session/manager.go, the config key, the README row and thecmd/routerlines, once getstream.io#1264 is live on the prod site.🤖 Generated with Claude Code