fix(agents): enforce visibility guard after sessionId resolution in session_status#52135
Conversation
…ession_status
When a sessionId (rather than an explicit agent key) is passed to the
session_status tool, the sessionId resolution block rewrites
requestedKeyRaw to an explicit "agent:..." key. The subsequent
visibility guard check at line 375 tested
`!requestedKeyRaw.startsWith("agent:")`, which was now always false
after resolution — skipping the visibility check entirely.
This meant a sandboxed agent could bypass visibility restrictions by
providing a sessionId instead of an explicit session key.
Fix: use the original `isExplicitAgentKey` flag (captured before
resolution) instead of re-checking the dynamic requestedKeyRaw.
This ensures the visibility guard runs for sessionId inputs while
still skipping the redundant check for inputs that were already
validated at the earlier explicit-key check (lines 281-286).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR fixes a security bypass in
Confidence Score: 5/5
Last reviewed commit: "fix(agents): enforce..." |
|
Closing this as implemented after Codex review. Current What I checked:
So I’m closing this as already implemented rather than keeping a duplicate issue open. Review notes: reviewed against 60f7a59f5ed5; fix evidence: release v2026.4.22, commit 00bd2cf7a376. |
Summary
session_statusreceives a sessionId (not an explicitagent:...key), the sessionId resolution block (lines 328-357) rewritesrequestedKeyRawto an explicit agent key!requestedKeyRaw.startsWith("agent:"), which becomesfalseafter resolution — skipping the visibility check entirelyRoot cause
The visibility guard has two check sites:
agent:...keyAfter sessionId resolution at line 340,
requestedKeyRawis overwritten to an explicit agent key. The condition at line 375 re-evaluates the now-mutatedrequestedKeyRawand concludes it starts with"agent:", so it skips the visibility check — even though check #1 also never ran (since the original input was not an explicit key).Fix
Replace
!requestedKeyRaw.startsWith("agent:")with!isExplicitAgentKey, which was captured at line 306 before sessionId resolution and reflects whether the original input was an explicit agent key.isExplicitAgentKey = true→ skip (already checked at line 281)isExplicitAgentKey = false→ run visibility checkTest plan
🤖 Generated with Claude Code