Skip to content

[Bug]: empty --terminal handle is accepted and silently targets the worktree-active pane #16694

Closed

Description

@meiai-iwagami

Operating system: macOS

Orca version: 1.4.188

Summary

orca terminal read|show --terminal "" returns exit 0 and operates on a live pane instead of failing. The empty string is treated the same as omitting --terminal. Garbage / whitespace handles correctly fail with terminal_handle_stale (exit 1).

Documented behavior (live orca terminal read --help, 2026-08-27):

Omit --terminal to target the active terminal in the current worktree.

That sentence is about omission. An explicit empty string is not omission. Scripts that do --terminal "$HANDLE" when HANDLE is empty therefore succeed against whichever pane Orca currently considers active in the worktree — which may be a different tab/pane than the calling process.

Environment

  • Orca desktop 1.4.188 (from orca status --json → runtime.appVersion)
  • macOS 26.5.1
  • Worktree with at least two live panes (a leftover shell tab and an agent tab). Commands below were issued from the agent pane.

Repro

Use any Orca-managed worktree that has two live panes (different handles). Placeholders: term_A = the pane running the commands, term_B = the other live pane.

orca terminal list --worktree current --json
# note two handles, here called term_A (caller) and term_B (other pane / other tab)

# 1) omitted flag (documented)
orca terminal show --json
# exit 0; JSON handle == term_B in this run (worktree-active, not necessarily the caller)

# 2) explicit empty string (the bug)
orca terminal show --terminal "" --json
orca terminal read --terminal "" --limit 2 --json
# exit 0; ok=true; same handle as omitted (term_B), not an error

# 3) invalid handles (control — already fail closed)
orca terminal show --terminal "term_deadbeef" --json
orca terminal show --terminal " " --json
# exit 1; error.code == "terminal_handle_stale"

# 4) wait
orca terminal wait --terminal "" --for tui-idle --timeout-ms 800 --json
# exit 1; error.code == "timeout"  (bound to a live pane, then timed out)
orca terminal wait --terminal "term_deadbeef" --for tui-idle --timeout-ms 800 --json
# exit 1; error.code == "terminal_handle_stale"

Actual

argv exit result
show / read with --terminal omitted 0 live pane (here: not the caller)
show / read --terminal "" 0 same pane as omitted
show / read --terminal " " 1 terminal_handle_stale
show / read --terminal term_deadbeef 1 terminal_handle_stale
show / read --terminal <caller handle> 0 caller pane
wait --terminal "" --for tui-idle --timeout-ms 800 1 timeout (same class as omitted)
wait --terminal term_deadbeef --for tui-idle --timeout-ms 800 1 terminal_handle_stale

In this measurement, empty/omitted resolved to a pane in a different tab than the process that issued the CLI command.

Expected

  • Omitting --terminal may keep targeting the worktree-active pane (documented).
  • --terminal "" and other empty/invalid values should fail closed (nonzero), same family as terminal_handle_stale.
  • A script must not be able to silently read or wait on the wrong pane because a variable expanded to empty.

Harm

Orchestration scripts commonly pass --terminal "$HANDLE". If the variable is empty, the CLI currently reports success and returns some other pane in the worktree. The caller can then treat that screen as the intended target (wrong agent, wrong tab). This is a diagnostic footgun: the failure mode looks like a successful read.

Workaround

  • Treat empty handle as a script error before calling Orca ([ -n "$HANDLE" ]).
  • Never omit --terminal in multi-pane worktrees unless the worktree-active pane is truly intended.
  • Do not infer identity from “the command ran in this pane”; compare the returned handle to the expected one.

Caveat (not probed)

terminal send / close / split / rename were not called with an empty handle, to avoid mutating another pane. Unknown whether the same fallback applies to those verbs.

Notes for Orca

Related-but-different public work: CLI already fails some missing-handle cases (e.g. create-without-handle). Empty string on read/show/wait still aliases to “omit”.

Activity

  1. Cunninger commented on Aug 27, 2026

    @Cunninger
    Contributor

    Opened a fix in #16745 — empty --terminal now fails closed instead of silently targeting the worktree-active pane.

  2. Tauri-EPO commented on Aug 31, 2026

    @Tauri-EPO
    Contributor

    Same flaw in terminal send — and there it is a write, not a read (Windows, 1.4.193)

    This issue documents terminal read|show. orca terminal send --terminal "" behaves identically, but the consequence is different in kind: instead of reading the wrong pane, it injects input into the wrong agent's terminal.

    Repro (Orca 1.4.193, Windows 11)

    $ orca terminal send --terminal "" --text "SONDA" --json
    {
      "ok": true,
      "result": { "send": { "handle": "term_fd6ae94c-e85a-4ae9-a36d-da40847007dd",
                            "accepted": true, "bytesWritten": 5 } }
    }
    

    Exit 0, accepted: true, and the response even reports the handle it silently chose — a pane the caller never named. Note that the returned handle is the only signal that anything went wrong; ok/accepted/bytesWritten all look like success.

    What it cost in practice

    An orchestration script of mine resolved a terminal handle from orca orchestration worker-show --dispatch <id>, where the dispatch had already settled — in that state terminalResource.terminalHandle comes back absent, and the empty string propagated into --terminal "$HANDLE".

    Three payloads went to a pane I never addressed, which turned out to be another Claude Code session (a different orchestrator, working on different PRs in the same worktree):

    1. a full task prompt: "Read and execute logs/briefing-fix-4883-r18.md in this worktree. Task ID task_5011dff92cbd."
    2. a bare teste
    3. the SONDA above

    That session replied to me out of band. It refused to execute and explained why, which is what prevented actual damage: it would have written a fix for the wrong PR into a worktree that already held its own uncommitted work, and in our setup the merge gate locates a lane by branch — two lanes sharing a worktree breaks that resolution. Its checks before refusing: the briefing file did not exist in its worktree, and the task id did not belong to its run.

    So the failure mode for send is not "reads the wrong pane": it is cross-agent prompt injection that reports success. With autonomous agents on both ends, whether it causes damage depends on the receiver being suspicious enough to refuse.

    Suggested handling

    Same as this issue asks for read/show — reject an explicit empty string with the existing terminal_handle_stale-style error instead of treating it as omission. For send specifically, I would argue an explicit empty handle should never fall back to an active pane at all, even if omission continues to: writing into an unnamed terminal has no safe default.

    Workaround on the caller side (in case it helps others): validate ^term_[0-9a-f-]{8,}$ before sending, and compare result.send.handle in the response against the handle you asked for — the response does carry enough information to detect the misdelivery after the fact.

  3. added
    bug
    os:macos
    on Sep 19, 2026
  4. added theissue type on Sep 19, 2026
  5. added a commit that references this issue on Oct 26, 2026
    d290035
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

buggitos:macos

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions