Repository navigation
Description
Summary
The `GET /api/operator-queue` endpoint returns operator queue items (pending agent approval prompts) for all agents on the platform, regardless of whether the requesting user owns or has access to those agents. A regular authenticated user can read — and potentially respond to — approval requests belonging to other users' agents.
Context
Identified during pentest remediation (High severity, 3.1.3 Broken Access Control [User]). The pentest screenshot confirms a user querying `GET /api/operator-queue?limit=200` and receiving items from agents they do not own, including the literal shell command pending approval (`ping -c 4 8.8.8.8`).
This is blocking the Letter of Attestation (A grade) from the security vendor.
Acceptance Criteria
- `GET /api/operator-queue` filters results to agents the requesting user owns or has been shared access to (same access model as `GET /api/agents`)
- `GET /api/operator-queue/stats` applies the same user-scoped filter
- `GET /api/operator-queue/agents/{name}` enforces that the requesting user has access to `{name}`
- `GET /api/operator-queue/{id}` returns 403 if the item belongs to an agent the user cannot access
- `POST /api/operator-queue/{id}/respond` returns 403 if the user cannot access the owning agent
- `POST /api/operator-queue/{id}/cancel` returns 403 if the user cannot access the owning agent
- Admin users continue to see the full queue (no regression)
- Existing `test_operator_queue` tests pass; add test for cross-user isolation
Technical Notes
Fix lives in `src/backend/routers/operator_queue.py`. The query in `db/operator_queue.py` (or equivalent) needs a JOIN or subquery against `agent_ownership` + `agent_sharing` filtered by `current_user.id`, mirroring the pattern used in `routers/agents.py` `list_agents`. Admin bypass: `current_user.role == "admin"` skips the filter.
Related: the Operating Room UI page (`/operating-room`) also renders these items — confirm the frontend filter follows from the fixed API response rather than needing its own change.
Activity
fix(security): operator-queue access control — scope items to accessi…