fix: close session ownership gaps on metrics, tools, latency, screenshot, events, stats (#1399)#1607
Merged
OneStepAt4time merged 1 commit intodevelopfrom Apr 10, 2026
Merged
Conversation
…hot, events, stats (#1399) - Add requireOwnership() to /v1/sessions/:id/metrics - Add requireOwnership() to /v1/sessions/:id/tools - Add requireOwnership() to /v1/sessions/:id/latency - Add requireOwnership() to /v1/sessions/:id/screenshot - Add requireOwnership() to /v1/sessions/:id/events - Scope /v1/sessions/stats by caller ownership for non-master keys - Consensus route removed (already removed in #1583)
1dda0e4 to
d72ba07
Compare
Contributor
There was a problem hiding this comment.
✅ Approved.
Fixes #1399 — Session ownership gaps closed on 6 endpoints.
Endpoints now guarded:
GET /v1/sessions/:id/metrics— requireOwnershipGET /v1/sessions/:id/tools— requireOwnershipGET /v1/sessions/:id/latency— requireOwnershipPOST /sessions/:id/screenshot— requireOwnershipGET /v1/sessions/:id/events(SSE) — requireOwnershipGET /v1/sessions/stats— scoped by ownerKeyId for non-master keys
Notes:
- Uses existing
requireOwnership()pattern — consistent with codebase - Stats endpoint correctly scopes: master sees all, non-master filtered by ownerKeyId, null/unset = legacy pass-through
- Missing from original #1597: consensus handler ownership + ownerKeyId propagation on child sessions. Recommend a follow-up PR for those.
1 file, 17 lines. CI green. Clean rebase.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add ownership checks to 6 per-session routes that were missing them:
Changes
Security
Without these checks, any API key could read metrics, tool usage, latency, screenshots, and event streams for sessions they don't own.
PR Stats