Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): require operate scope for local server discovery probes #7789

ClosedLucenx9(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/7789/headopened View on GitHub

What 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.

Macroscope summarized e02277d.

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. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Review Change Stack

      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.ts
      • apps/server/src/auth/RpcAuthorization.ts

      Included 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

      Layer / File(s)Summary
      Update subscription scope and test coverage
      apps/server/src/auth/RpcAuthorization.ts, apps/server/src/auth/RpcAuthorization.test.ts
      subscribeDiscoveredLocalServers now requires AuthOrchestrationOperateScope. The test verifies the mapping.

      Estimated code review effort: 1 (Trivial) | ~2 minutes

      Merge Risk: ⚪ Minimal · up to e0227

      The 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)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely identifies the main authorization change for local server discovery probes.
      Description check✅ PassedThe description explains the change, security rationale, impact, validation, and checklist status in sufficient detail.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      ✅ 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.

    4. 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).

Sign in to join this conversation.