fix(server): require operate scope for local server discovery probes #7789
main fromrefs/pull/7789/head·opened View on GitHubWhat Changed#
subscribeDiscoveredLocalServers now requires orchestration:operate instead of orchestration:read, and a focused test pins that decision.
Why#
The preview discovery RPC accepts client-supplied configuredUrls and probes them with server-side HTTP GETs (PortScanner.probeWebUrl), but was authorized with orchestration:read. A read-only paired client - or project previewUrl configuration it causes the UI to forward - could make the environment server request arbitrary loopback paths, queries, and ports, crossing the read-only RPC boundary into local network side effects. The documented contract for orchestration:read (docs/internals/environment-auth.md) covers snapshots, status, events, configuration, and filesystem/VCS state; probing local services is not a read.
Impact is bounded (auth required, loopback-only hosts, 32 URLs x 2048 chars, GET only, no response body, redirects not followed), so this is a scope-hygiene fix rather than an incident response. Read-only devices lose the Local recommendations list in the preview empty state; every other client is unaffected.
Found by an automated security review; validated with a test that starts a loopback HTTP server, hides it from listener enumeration, and asserts a configured URL still receives a GET.
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes
ox-alpha via opencode
Note
Medium Risk Touches RPC authorization for a method that issues server-side loopback GETs. The change is a one-line scope tightening with a unit test, not a new attack surface.
Overview
Tightens auth so subscribeDiscoveredLocalServers requires orchestration:operate instead of orchestration:read. That RPC probes client-supplied loopback URLs, which is a side effect, not a snapshot/status read.
Read-only paired clients lose the Local recommendations list in the preview empty state; other clients are unchanged. A unit test pins the required scope.
Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit e02277de7cdc8f580c1b7be0425d1774ffede80a. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).Note
Require AuthOrchestrationOperateScope for subscribeDiscoveredLocalServers RPC#
Updates the RPC_REQUIRED_SCOPES mapping in RpcAuthorization.ts so WS_METHODS.subscribeDiscoveredLocalServers requires AuthOrchestrationOperateScope instead of AuthOrchestrationReadScope. Adds a test case in RpcAuthorization.test.ts asserting the new scope. Risk: clients with only read scope can no longer subscribe to local server discovery probes.
Summary by CodeRabbit#
Bug Fixes
- Improved authorization for local server discovery subscriptions by requiring elevated orchestration permissions.
Tests
- Added coverage to verify that unauthorized subscriptions are rejected.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XS
@coderabbitai review
✅ Action performed
Review finished.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This PR modifies authorization scope requirements in the auth directory. Per policy, changes to auth/security packages require human review regardless of simplicity, even when the change makes access more restrictive.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).Lucenx9(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
2c18ab90-ea77-41f6-81c6-07997a983dab📥 Commits
Reviewing files that changed from the base of the PR and between be7d35aaeb49a04483ec5e0d2284e8b5b70a3b6e and e02277de7cdc8f580c1b7be0425d1774ffede80a.
📒 Files selected for processing (2)
apps/server/src/auth/RpcAuthorization.test.tsapps/server/src/auth/RpcAuthorization.tsIncluded review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
Walkthrough#
The local server discovery subscription now requires orchestration operate authorization, with a test covering the updated mapping.
Changes#
Authorization scope correction
apps/server/src/auth/RpcAuthorization.ts,apps/server/src/auth/RpcAuthorization.test.tssubscribeDiscoveredLocalServersnow requiresAuthOrchestrationOperateScope. The test verifies the mapping.Estimated code review effort: 1 (Trivial) | ~2 minutes
Merge Risk: ⚪ Minimal · up to
e0227The change limits local server discovery probes to clients with operate permission; no actionable merge-blocking risk remains after normal checks and review.
Suggested reviewers:
bil0000,t3dotgg🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share