Skip to content

fix(devices): refuse a pane's file paths and a plugin run's output to a watching device (#2244) - #2252

Merged
devswha merged 1 commit into
mainfrom
fix/watch-pane-files-permission
Oct 28, 2026
Merged

devswha merged 1 commit into
mainfrom
fix/watch-pane-files-permission

Conversation

@devswha

@devswha devswha commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

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

  • Access check (server/index.ts): the watch refusal covers pane/files and plugin/action 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 pane/files or plugin/action with the PC's credential, just as pane/commands, agent/commands and sessions/history are not forwarded.
  • Client: no change. The composer (the only caller of fetchPaneFiles, for @-mentions) is never mounted for an observer (PaneTerminal's !observing) and does not retry on a backoff. pluginRun polls 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

route why it stays
pane/read, pane/scroll, pane/selection the terminal screen, which the watcher already watches
pane/conversation*, pane/plan, pane/omo-tasks, pane/background-agent the chat view and its panels, which a watcher sees
pane/prompt a watcher already gets the screen's card without Claude's plan file (plan=0)
pane/find a POST, already refused
worktree/list the sidebar asks it on every device for branch names; trimming its answer is #2250
agents, integrations, plugins/actions, session no paths, file contents or commands

Tests

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 403 read_only for both routes on the local, local-alias and remote paths. A driving device reaches them (pane_not_found and plugin_log_not_found for 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 for pane/files or plugin/action for a read-only connection, and passes a driving device the PC's answers.

bun run check fast passes.

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 with curl -i:

device path answer
watch /api/pane/files, /api/machines/local/pane/files, /api/machines/pc1/pane/files 403 read_only
watch /api/plugin/action, /api/machines/local/plugin/action, /api/machines/pc1/plugin/action 403 read_only
drive /api/pane/files, /api/machines/local/pane/files 200 {"files":[".commandcode/commands/deploy.md"]}
drive /api/plugin/action, /api/machines/local/plugin/action 404 plugin_log_not_found (no such run)
drive /api/machines/pc1/… (both) 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. On a real server (port 0, no herdr) it tried GET, HEAD and OPTIONS, odd path spellings (//, a trailing slash, %66iles, case, ;x, ./, ../), WS frames and the relay, and found no way to these answers. LOWs:
    1. The driving-device check on plugin/action only asserted "not a 403". Fixed: it now asserts 404 plugin_log_not_found.
    2. The proxy's refusal list repeats part of the access check's. Accepted: it is the existing pattern (Watch devices can read pane command rows that /api/agent/commands refuses them #2132), and the access check always runs first.
    3. (pre-existing) /api/pane/conversation/tool-output gives 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.
  • Codex Sol 6.1 fast xhigh: APPROVE. 450 path/query probes and 48 method/prefix checks found no bypass. Driving devices, the owner bearer and the bridge bearer keep access. Pre-existing, outside this diff:
    • MEDIUM: /api/worktree/list shows 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.
    • LOW: a watcher's terminal Find bar submits a POST that is refused (403), so it shows an error. Left as is: there is no retry loop. Disabling it for observers is a UI choice outside this fix.

No REMOTE_BUNDLE_VERSION change: only a release PR raises it.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between af13338 and fbb6bc3.

Files selected for processing: 5
  • changelog.d/watch-pane-files-refused.md
  • server/device-access.contract.test.ts
  • server/index.ts
  • server/machine-api.ts
  • server/machine-proxy.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Review record for head 1802b30 (CodeRabbit skips a PR whose base is not main; this one stacks on #2246):

Reviews

This touches observe permissions and an HTTP contract, so it was reviewed adversarially before opening:

  • omo-native-code-reviewer: APPROVE. On a real server (port 0, no herdr) it tried GET, HEAD and OPTIONS, odd path spellings (//, a trailing slash, %66iles, case, ;x, ./, ../), WS frames and the relay, and found no way to these answers. LOWs:
    1. The driving-device check on plugin/action only asserted "not a 403". Fixed: it now asserts 404 plugin_log_not_found.
    2. The proxy's refusal list repeats part of the access check's. Accepted: it is the existing pattern (Watch devices can read pane command rows that /api/agent/commands refuses them #2132), and the access check always runs first.
    3. (pre-existing) /api/pane/conversation/tool-output gives 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.
  • Codex Sol 6.1 fast xhigh: APPROVE. 450 path/query probes and 48 method/prefix checks found no bypass. Driving devices, the owner bearer and the bridge bearer keep access. Pre-existing, outside this diff:
    • MEDIUM: /api/worktree/list shows 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.
    • LOW: a watcher's terminal Find bar submits a POST that is refused (403), so it shows an error. Left as is: there is no retry loop. Disabling it for observers is a UI choice outside this fix.

No HIGH or MEDIUM finding remains open on this change.

Base automatically changed from fix/watch-pane-commands-permission to main October 28, 2026 12:52
… 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.
@devswha
devswha force-pushed the fix/watch-pane-files-permission branch from 1802b30 to fbb6bc3 Compare October 28, 2026 12:55
@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

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.

@devswha

devswha commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

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 /api, /api/machines/local and /api/machines/<id>; this PR answers 403 read_only on all six while a driving device still gets 200 with the data. Path spellings, HEAD and OPTIONS give 403 or 404 to the watcher, a watcher's POST /api/plugin/action stays 403, and the PC proxy refuses both before forwarding. No other route lists pane files or returns plugin run output to a watcher (/plugins/actions returns action metadata only; /fs/* and /workspace/directories were already refused). omo's matrix of 896 watch attempts (16 spellings, 7 methods, local, alias, remote and direct proxy) got no data and never reached the upstream, and both new tests fail on #2246's head. Closes #2244. Not filed: some malformed local-alias spellings answer 400 invalid_route rather than 403/404, as before, with no data.

@devswha
devswha merged commit fec98dc into main Oct 28, 2026
20 checks passed
@devswha
devswha deleted the fix/watch-pane-files-permission branch October 28, 2026 13:39
devswha added a commit that referenced this pull request Oct 29, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watch devices can list a pane folder's file paths through /api/pane/files

1 participant