Repository navigation
fix(gateway): prevent cross-client system-agent session takeover - #111565
Conversation
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(gateway): prevent cross-client system-agent session takeover This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42f77a3a14
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const connId = params.client?.connId?.trim(); | ||
| return connId ? `connection:${connId}` : undefined; |
There was a problem hiding this comment.
Preserve ownership across device-less CLI requests
When a caller has no authenticated user or device identity, binding the session to connId breaks multi-turn CLI conversations because callGatewayCli creates and stops a WebSocket for every RPC (src/gateway/call.ts:947-971,995-1013). This occurs for loopback token/password calls, where device identity is deliberately omitted (src/gateway/call.ts:486-512,1185-1190), and when identity loading fails in a restricted environment. runRemoteGatewayInferenceOnboarding sends the welcome and each reply through separate calls (src/commands/onboard-remote-gateway.ts:267-295), so its second turn gets a new connection key and is rejected as belonging to another caller. Use a stable authenticated owner for this flow or keep its connection alive instead of treating the per-request connection ID as session identity.
Useful? React with 👍 / 👎.
|
Codex review: needs real behavior proof before merge. Reviewed July 19, 2026, 7:00 PM ET / 23:00 UTC. Summary PR surface: Source +35, Tests +275. Total +310 across 4 files. Reproducibility: yes. from source: invoke the session once through a device-less loopback token/password CLI call, then send the next turn through its normal new WebSocket connection. The owner falls from the original connection ID to a different one and the session check rejects it. Review metrics: none identified. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Keep unidentifiable callers connection-bound for security, then make the affected onboarding/CLI conversation reuse one authenticated gateway connection across its system-agent turns; add an integration regression that proves both cross-client rejection and the device-less multi-turn path. Do we have a high-confidence way to reproduce the issue? Yes, from source: invoke the session once through a device-less loopback token/password CLI call, then send the next turn through its normal new WebSocket connection. The owner falls from the original connection ID to a different one and the session check rejects it. Is this the best way to solve the issue? No. Binding unidentifiable clients to Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a0c3067b545b. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +35, Tests +275. Total +310 across 4 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
Merged via squash.
|
…nclaw#111565) * fix(gateway): bind system-agent sessions to callers * test(gateway): type system-agent response helper
…nclaw#111565) * fix(gateway): bind system-agent sessions to callers * test(gateway): type system-agent response helper
What Problem This Solves
Fixes an issue where a second authenticated client on a shared gateway could submit turns, approve a pending proposal, or reset another client's non-delegated system-agent chat when it knew or guessed that chat's session ID. Non-delegated sessions previously collapsed onto the same empty ownership key, so the existing session-binding check did not distinguish callers.
Threat model: two authenticated gateway clients, one known or guessable system-agent session ID, and no explicit host delegation. The second client must not learn session data or drive the first client's setup/configuration conversation.
Why This Change Was Made
Every system-agent session now has a required owner key. Explicit host-only delegation keeps its existing agent/session tuple so intentional cross-connection delegation continues to work; ordinary calls use the authenticated user identity, then the cryptographically verified paired-device identity, and finally the server-issued connection ID. Ownership is checked before any session message, approval response, or reset is processed, and mismatches return the existing redacted invalid-request response.
This is an additive gateway-internal ownership check. It does not change or version the gateway protocol, configuration, or persistent state.
User Impact
Control UI, CLI, and native clients can continue their own system-agent chats across legitimate reconnects, while another authenticated gateway client can no longer take over those sessions by replaying a session ID. Existing explicit regular-agent delegation behavior is unchanged.
Evidence
AI-assisted: yes. The behavior, trust boundary, regression proof, and reconnect semantics were reviewed directly.