Repository navigation
fix(devices): refuse a pane's file paths and a plugin run's output to a watching device (#2244) - #2252
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 20 minutes. View limit details
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. Comment |
|
Review record for head 1802b30 (CodeRabbit skips a PR whose base is not ReviewsThis touches observe permissions and an HTTP contract, so it was reviewed adversarially before opening:
No HIGH or MEDIUM finding remains open on this change. |
… a watching device (#2244) A watch-only device could list up to 100 paths under a pane's folder through GET /api/pane/files (the composer's @-mention picker), on this PC, its /api/machines/local alias and another PC's route, while a directory listing was already refused. GET /api/plugin/action (where a plugin run stands, with what its command printed when it failed) was open the same way. Both are now refused with 403 read_only at the access check, and the PC proxy never asks a PC for them with its credential for a read-only connection. Driving devices keep both routes.
1802b30 to
fbb6bc3
Compare
|
@coderabbitai review |
|
|
Merging fbb6bc3 (#2252 rebased onto main after #2246 merged; its own diff is unchanged from the reviewed 1802b30). An access change, so it got a strict review; Codex was at capacity, so an omo reviewer on gpt-6.1-sol and an independent second reviewer reviewed it; both pass with no HIGH or MEDIUM. It was stacked on #2246 and was reviewed as its own commits on top of #2246's head. Against real fixtures (an isolated herdr pane, a real plugin run's log id, a second server as a remote PC), #2246's head gave a watch device the pane's file names and the plugin run's output on |
…2250) (#2304) Closes #2250. Follows #2246 and #2252 (merged), which refused a watching device a pane's command rows, the paths under a pane's folder and a plugin run's output the same way: refused, not trimmed. ## Change A watch-only device was refused a directory listing, but `GET /api/worktree/list?workspace_id=…` gave it herdr's whole worktree inventory for that workspace's repository: every checkout's absolute path, branch and label, including checkouts not open in herdr. The issue suggested trimming the answer, because the sidebar reads it on every device for branch names. Per the owner's decision for #2246/#2252 (refuse instead of hiding), the route is now refused to a watching device, and the client stops asking. - **Access check** (`server/index.ts`): the watch refusal covers `worktree/list` on this PC, on its `/api/machines/local/` alias and on another PC's `/api/machines/<id>/` route, answering 403 `read_only`. - **PC proxy** (`server/machine-api.ts`): a read-only connection is never forwarded `worktree/list` with the PC's credential, just as `pane/files`, `pane/commands`, `agent/commands`, `plugin/action` and `sessions/history` are not. - **Client:** - `useWorktreeBranches` takes `watching`: while watching it asks nothing, and a `read_only` answer stops its 30 s poll instead of retrying it forever. Its cache is keyed on the PC and the role, so a device signed in to drive reads branches again, and a downgrade drops the branches it had learned. - The sidebar passes `watching`, skips its per-workspace "is this a repository" probe while watching, and hides New worktree / Open worktree (drive features whose dialog lists the checkouts), as it already hides Earlier sessions. - The command palette gets `watching` from `App` and mounts no branch readers while watching. - **Visible tradeoff:** a watching device no longer shows branch names in the sidebar or the palette. A driving device, the owner's token and the connection server's bridge token keep the route on every path. ## Sweep of `server/workspace-routes.ts` | route | state | | --- | --- | | `workspace/directories` (GET) | already refused (directory listing) | | `workspace/diff/files`, `diff/file`, `diff/refs` (GET) | already refused (repository diff) | | `worktree/list` (GET) | refused by this PR | | every other route (`workspace/*`, `tab/*`, `worktree/create|open|remove`) | POST, already refused as a mutation | ## Tests Each new test failed on the code before the fix and passes after it: - `server/device-access.contract.test.ts`: a watching device gets 403 `read_only` on the local, local-alias and remote paths. A driving device reaches the route (`workspace_not_found` locally and through the alias for an absent workspace, 503 for an unconnected PC). Before the fix the local and alias paths answered 404, not 403. - `server/machine-proxy.test.ts`: the proxy never asks a PC for `worktree/list` for a read-only connection, and passes a driving device the PC's answer. - `src/lib/useWorktreeBranches.hook.test.ts` (new): a driving device polls again after 30 s. After a `read_only` answer the hook asks once and never again (it asked again before the fix). While watching it asks nothing, and after a switch to drive it reads and polls again (this failed with the refusal kept per PC only). `bun run check fast` passes. ## Manual QA An isolated Ovis server (mkdtemp state dir, port 0, the `ovis-test` herdr session) has a workspace on a repository with one linked checkout, `secret-branch`, not open in herdr. Each path was requested with `curl -i`: | device | path | answer | | --- | --- | --- | | watch | `/api/worktree/list`, `/api/machines/local/worktree/list`, `/api/machines/pc1/worktree/list` | 403 `read_only` | | drive | `/api/worktree/list`, `/api/machines/local/worktree/list` | 200, the inventory | | drive | `/api/machines/pc1/worktree/list` | 503 `machine_offline` (no such PC connected) | ## Reviews This touches observe permissions and an HTTP contract, so it was reviewed adversarially before opening: - **omo-native-code-reviewer: APPROVE** (after one fix round). It probed `./`, `%2e`, `../`, `\`, `%6cist`, `;x`, case, `//` and a trailing `/`, plus GET, HEAD and OPTIONS. It also checked the WS and relay surfaces and the check order (the refusal runs before the alias rewrite and the proxy). It found no way to the answer. - MEDIUM: the `read_only` refusal was kept per PC, so a device signed in to drive later never read branches again until reload. **Fixed:** the hook's cache is keyed on the role, and there is a test for watch → drive. - LOW: the palette sent one refused request per open on a watching device. **Fixed:** it mounts no branch readers while watching. - LOW: branches learned before a downgrade stayed shown. **Fixed** by the same role-keyed cache. - LOW: the sidebar gating has no component test. **Left:** it matches the existing Earlier sessions gate, and the hook carries the behaviour. - LOW (after the fix): a refusal that arrives, followed by a downgrade and an upgrade, all between two health polls, keeps the refusal until reload. **Left:** it needs two role changes inside one poll interval. - LOW (both reviewers, and CodeRabbit as Minor): the palette kept the branches it read while driving after a switch to watching. It stays mounted while closed, so they outlived closing it too. **Fixed** in a follow-up commit: while watching, its branches are empty and the cached inventories are cleared. - **Codex Sol 6.1 fast xhigh:** **APPROVE** (after one fix round, re-reviewed on the fix only). It ran 532 method/path combinations without finding a watch-device bypass, and confirmed the new server tests fail against the unfixed code. - MEDIUM: the same refusal-outlives-role-change bug. **Fixed** as above. - LOW: cached branches survive a downgrade. **Fixed** as above. - LOW (pre-existing credential precedence): a request carrying both a valid bridge bearer and a watch device cookie is treated as the watch device, so it is now refused this route. **Left:** the bridge proxy strips cookies, so real bridge traffic never carries one. Changing which credential wins is outside this fix. No `REMOTE_BUNDLE_VERSION` change: only a release PR raises it.
Closes #2244.
Follows #2246 (merged as af13338), which refused a pane's command rows the same way: refused, not hidden.
Change
A watch-only device was refused a directory listing and file reads, but
GET /api/pane/files?pane_id=…&q=…gave it up to 100 relative paths under the pane's folder. Sweeping the other/api/pane/*, file and plugin routes turned up one more of the same kind:GET /api/plugin/action?plugin_id=…&log_id=…answers where a plugin action's run stands, including the tail of what its command printed when it failed, to anyone holding a log id. Only the device that started the run asks it (after its own POST, which a watcher cannot send).server/index.ts): the watch refusal coverspane/filesandplugin/actionon this PC, on its/api/machines/local/alias and on another PC's/api/machines/<id>/route, answering 403read_only.server/machine-api.ts): a read-only connection is never forwardedpane/filesorplugin/actionwith the PC's credential, just aspane/commands,agent/commandsandsessions/historyare not forwarded.fetchPaneFiles, for @-mentions) is never mounted for an observer (PaneTerminal's!observing) and does not retry on a backoff.pluginRunpolls the GET only after its own POST.A driving device and the connection server's bridge token keep both routes on every path.
Sweep: what stays open to a watcher, and why
pane/read,pane/scroll,pane/selectionpane/conversation*,pane/plan,pane/omo-tasks,pane/background-agentpane/promptplan=0)pane/findworktree/listagents,integrations,plugins/actions,sessionTests
Each new test failed on the code before the fix (#2246's head) and passes after it:
server/device-access.contract.test.ts: a watching device gets 403read_onlyfor both routes on the local, local-alias and remote paths. A driving device reaches them (pane_not_foundandplugin_log_not_foundfor absent ones locally and through the alias, 503 for an unconnected PC). Before the fix the local path answered 404 instead of 403.server/machine-proxy.test.ts: the proxy never asks a PC forpane/filesorplugin/actionfor a read-only connection, and passes a driving device the PC's answers.bun run check fastpasses.Manual QA
An isolated Ovis server (mkdtemp state dir, port 0, the check run's own herdr session) has a pane in a folder holding
.commandcode/commands/deploy.md. Each path was requested withcurl -i:/api/pane/files,/api/machines/local/pane/files,/api/machines/pc1/pane/filesread_only/api/plugin/action,/api/machines/local/plugin/action,/api/machines/pc1/plugin/actionread_only/api/pane/files,/api/machines/local/pane/files{"files":[".commandcode/commands/deploy.md"]}/api/plugin/action,/api/machines/local/plugin/actionplugin_log_not_found(no such run)/api/machines/pc1/…(both)machine_offline(no such PC connected)Reviews
This touches observe permissions and an HTTP contract, so it was reviewed adversarially before opening:
//, a trailing slash,%66iles, case,;x,./,../), WS frames and the relay, and found no way to these answers. LOWs:plugin/actiononly asserted "not a 403". Fixed: it now asserts 404plugin_log_not_found./api/pane/conversation/tool-outputgives a watcher a tool call's complete output, while the chat shows it cut at 4000 characters. Left as is: that output is already in the chat view a watcher sees./api/worktree/listshows a watcher the paths and branches of checkouts not open in herdr. Filed as Watch devices see unopened worktree paths and branches through /api/worktree/list #2250: it needs the answer trimmed rather than refused, because the sidebar uses the route on watching devices.No
REMOTE_BUNDLE_VERSIONchange: only a release PR raises it.