Should the host terminal be a trust boundary with its own filter?
Decided 2026-10-04: A. Boundary plus allowlist filter, for now. Decided 2026-10-06: 1A, reset on exit, and 2C, the full filter on every stream. The decisions and their reasons are in the I37I37 (closed): S03-requirements, S05-cli: treat the host terminal stream as a boundarywb claude relays the guest's PTY output in raw mode to the user's terminal emulator (S05-cli). comments that start Decision (2026-10-04): and Decision (2026-10-06):, and the filter’s contents in the I30I30 (closed): X19-terminal-filter: Terminal stream filteringX19-terminal-filter (added to S11-verification-and-spikes in #14) decision (B30-terminal-filterB30-terminal-filter: Can wb filter Claude Code's terminal output without breaking it?Yes, with conditions, for Ghostty and Terminal.app pending a check by eye.). The spec change from PR81PR81 (merged): docs(spec): treat the host terminal stream as a boundary- Decides: guest output reaching the user's terminal is boundary 6 of T00-index, and wb filters it with the allowlist measured in X19-terminal-filter (S05-cli, "Terminal stream"). is confirmed: T00-indexT00-indexboundary 6 is the host terminal stream., S05-cliS05-cli: Command Line InterfaceSpecify wb, the single user-facing command. (“Terminal stream”) and S11-verification-and-spikesS11-verification-and-spikesthe filter's fuzz properties, including one that replays the filtered output and the exit reset into a headless emulator and checks it is back in its initial state, and a conformance case that prints every dropped seq….
The problem
Section titled “The problem”Figure 1. The terminal of a wb claude session shows bytes the guest chose. Today nothing between the guest and the emulator looks at them. The red paths are escape sequences that make the emulator act on the host: OSC 52 writes the clipboard, and iTerm2’s OSC 1337 saves a file to Downloads.
The spec change
Section titled “The spec change”What the decisions on I37I37 (closed): S03-requirements, S05-cli: treat the host terminal stream as a boundarywb claude relays the guest's PTY output in raw mode to the user's terminal emulator (S05-cli). and I30I30 (closed): X19-terminal-filter: Terminal stream filteringX19-terminal-filter (added to S11-verification-and-spikes in #14) and the security review of PR66PR66 (merged): docs(spikes): X19-terminal-filter result, yes with conditionsAnswer: yes, with conditions, for Ghostty and Terminal.app, as far as a headless emulator can show. became, and where:
- T00-index: boundary 6 is the host terminal stream. A new accepted risk, T09-terminal-fingerprintT09-terminal-fingerprint: Host terminal facts in the guestThe guest learns the host terminal's name and version, its colors, the window size in cells and pixels, the state of its modes, and which program states it shows, from the replies to the queries S16-terminal-stream pa…, records what the guest learns about your terminal: its name and version, colors, window size, and seven environment variables.
- S05-cliS05-cli: Command Line InterfaceSpecify wb, the single user-facing command., “Terminal stream”: the allowlist as a table, tightened as PR66PR66 (merged): docs(spikes): X19-terminal-filter result, yes with conditionsAnswer: yes, with conditions, for Ghostty and Terminal.app, as far as a headless emulator can show.’s review asked (at most 16 parameters of at most 5 digits,
CSI 3 Jdropped, unrecorded modes dropped, the kitty keyboard stack at most 4 deep per screen, and the guest can’t change or pop an entry it didn’t push). OSC 52 is dropped, because V1V1-initial: Initial versionThe first version: what it delivers, what it leaves out, and the milestones that get there. has no clipboard (V1-08-no-forward-clipboardV1-08-no-forward-clipboard: No port forwarding or clipboardPort forwarding (FR11-port-forward) and the clipboard (FR12-clipboard) are out of scope for V1, so nothing new crosses the VM boundary for them (S06-vm-lifecycle).). Notifications become a bell, at most one per second. OSC 8 links are dropped on screen.wblists up to 100 of them with their text in the session summary and the audit log, and marks those whose name looks host-local or that aren’thttps://, as a heuristic.wbsets the window title itself, resets the terminal before the summary, drains late query replies on exit behind a query of its own, and passes exactlyTERM,TERM_PROGRAM,TERM_PROGRAM_VERSION,COLORTERM,LANG,LC_ALLandLC_CTYPEto the guest. - One change from the I37I37 (closed): S03-requirements, S05-cli: treat the host terminal stream as a boundarywb claude relays the guest's PTY output in raw mode to the user's terminal emulator (S05-cli). decision: it says
wbstrips control sequences from guest text outside the stream. The spec haswb diff, logs and audit records show them escaped instead, so you see them when you review. Other output removes them. - S11-verification-and-spikes: the filter’s fuzz properties, including one that replays the filtered output and the exit reset into a headless emulator and checks it is back in its initial state, and a conformance case that prints every dropped sequence and a fake summary.
- S03-requirementsS03-requirements: RequirementsThe problem Wraith Box solves, and where the requirements that answer it are. stays as it is, because it points at T00-indexT00-indexboundary 6 is the host terminal stream. for the boundaries.
Decision 1: how wb cleans up the terminal on exit. Decided 2026-10-06: 1A.
Decision 2: output to a pipe or a file. Decided 2026-10-06: 2C. The I37I37 (closed): S03-requirements, S05-cli: treat the host terminal stream as a boundarywb claude relays the guest's PTY output in raw mode to the user's terminal emulator (S05-cli). decision doesn’t make an exception for pipes, so this had no recommendation. The filter passes only output that is safe in a terminal, so a later cat of the file is as safe as the live session, and one filter keeps one code path and one fuzz target.
Options for the boundary (decided: A)
Section titled “Options for the boundary (decided: A)”The issue proposes A and doesn’t list alternatives. B, C and D are the alternatives as this brief sees them.
Impact
Section titled “Impact”Evidence
Section titled “Evidence”- verified Interactive
wb claudeis a raw-mode TTY relay, and S05-cliS05-cli: Command Line InterfaceSpecify wb, the single user-facing command. strips control and escape sequences only from the text ofwb approveandwb deny(S05-01-agent-commandsS05-01-agent-commands: Agent CommandsHow wb claude passes its arguments to Claude Code, how it runs interactive and non-interactive sessions, and what a session does. and S05-03-management-commandsS05-03-management-commands: Management CommandsThe commands of wb other than the agent commands.). - verified T00-indexT00-indexboundary 6 is the host terminal stream. lists five boundaries, and the host terminal is not one (“Model”).
- verified iTerm2 saves a file sent with
OSC 1337 ; File=and noinline=1to the Downloads folder, and copies text to the pasteboard withOSC 1337 ; Copy=(iTerm2 escape codes, iTerm2 images). - verified
git log --format=%swrites a commit subject containingESC ] 52 ; c ; …unchanged to its output (git 2.56.0, local test). - verified S11-verification-and-spikesS11-verification-and-spikesthe filter's fuzz properties, including one that replays the filtered output and the exit reset into a headless emulator and checks it is back in its initial state, and a conformance case that prints every dropped seq… requires a fuzz target for every parser of guest bytes (“Test layers”). The filter gets one under A, B, and C.
- verified Claude Code 2.1.289 draws the same screens through the allowlist, on replay in a headless emulator, except that links stop being links (X19-terminal-filterX19-terminal-filter: Terminal stream filteringWhich terminal escape sequences does Claude Code emit, and can wb drop the ones that act on the host (clipboard writes, file transfer, terminal multiplexer control sequences) without visible damage in the common macOS…, “What the filter changes”).
- verified The caps in S05-cliS05-cli: Command Line InterfaceSpecify wb, the single user-facing command. sit above what Claude Code sent: in the seven X19-terminal-filterX19-terminal-filter: Terminal stream filteringWhich terminal escape sequences does Claude Code emit, and can wb drop the ones that act on the host (clipboard writes, file transfer, terminal multiplexer control sequences) without visible damage in the common macOS… recordings a CSI has at most 5 parameters of at most 4 digits,
JandKtake only 2 or none, and the kitty keyboard stack is at most 1 deep (count over the recordings on the spike branch, for this spec change). - verified The X19-terminal-filterX19-terminal-filter: Terminal stream filteringWhich terminal escape sequences does Claude Code emit, and can wb drop the ones that act on the host (clipboard writes, file transfer, terminal multiplexer control sequences) without visible damage in the common macOS… recorder gave Claude Code
TERM,TERM_PROGRAM,TERM_PROGRAM_VERSIONandCOLORTERMper terminal profile, and the host’s own locale. Those are the variables S05-cliS05-cli: Command Line InterfaceSpecify wb, the single user-facing command. lets cross (cmd/record/main.goon the spike branch). - verified Plain
-ptext doesn’t hold escape sequences when standard output is a file. The X19-terminal-filterX19-terminal-filter: Terminal stream filteringWhich terminal escape sequences does Claude Code emit, and can wb drop the ones that act on the host (clipboard writes, file transfer, terminal multiplexer control sequences) without visible damage in the common macOS… recordings are all interactive, so this PR ran one probe: Claude Code 2.1.289,claude -p --model haikuasked for a heading, a table, bold text, a code block and a Markdown link, with output to a file. It wrote 528 bytes with noESCbyte. - assumed That Ghostty and Terminal.app answer the drain’s sentinel query
CSI ? 6 n. A terminal that doesn’t costs 100 ms on exit, and a reply that arrives after that can still reach your shell. I62I62 (closed): X19-terminal-filter: visual check in real terminalsSplit from #30 (X19-terminal-filter) during triage on 2026-10-04. can check it. - assumed That the headless emulator shows what Ghostty and Terminal.app show. I62I62 (closed): X19-terminal-filter: visual check in real terminalsSplit from #30 (X19-terminal-filter) during triage on 2026-10-04. checks it by eye.
- assumed Which macOS terminals act on OSC 52 by default. The answer varies per emulator and version. The filter drops it either way.
What this unblocks
Section titled “What this unblocks”- The terminal filter in V1-M4-claude-end-to-endV1-M4-claude-end-to-end: `wb claude` end to endGit round trip with carry-in, landing and flagging, the model credential, the terminal records and the session summary, wb diff and wb land, on a sealed image., once this spec change merges.
- I38I38 (closed): S06-vm-lifecycle: design port forwarding and clipboard (FR11-port-forward, FR12-clipboard) and their threatsFR11-port-forward (dev servers on host loopback) and FR12-clipboard (clipboard) cross the VM boundary, but no spec designs them and S03-requirements's threat model does not list them., whose clipboard design (B38-port-forward-clipboardB38-port-forward-clipboard: How should guest dev servers and clipboard text cross to the host?Forward HTTP through a host proxy that gives each forwarded port its own localhost site, plain TCP only on ports the user names, and the clipboard only through wb with an approval.) relies on OSC 52 never reaching the host.
Details and glossary
Why an allowlist. The filter is a security control on a parser of guest bytes, and the rest of the design fails closed (SEC05-default-denySEC05-default-deny: Default-deny egress, enforced on the hostOnly allowlisted hostnames are reachable. for the network). A denylist depends on knowing every sequence every emulator acts on, across releases. An allowlist depends only on what Claude Code needs, which X19-terminal-filterX19-terminal-filter: Terminal stream filteringWhich terminal escape sequences does Claude Code emit, and can wb drop the ones that act on the host (clipboard writes, file transfer, terminal multiplexer control sequences) without visible damage in the common macOS… measures once.
Dropped sequences. The filter removes a sequence that isn’t on the list rather than escaping it into visible text, which would shift the screen layout. The session summary reports how many it removed, which explains a broken render (NFR06-explained-refusalsNFR06-explained-refusals: OperabilityEvery refusal names the rule that caused it and how to change it.).
Input in the other direction. Keystrokes and replies from the emulator go into the guest. Those are host data in the guest. Replies to queries (cursor position, device attributes) are harmless, but a sequence that asks the emulator to report the clipboard (OSC 52 with ?) would send host clipboard content into the guest. Dropping OSC 52 in the output direction removes that too.
Glossary
- Escape sequence: bytes starting with
ESCthat a terminal emulator treats as a command (move the cursor, change color) rather than text. - OSC: Operating System Command, a family of escape sequences. OSC 52 sets or reads the clipboard. OSC 1337 holds iTerm2’s own commands.
- DCS: Device Control String, another family, used by multiplexers such as
tmuxand for graphics. - PTY: the pseudo-terminal in the guest that Claude Code writes to, as if it were a real terminal.
- Raw mode: the host terminal passes keystrokes straight through, and
wbpasses output straight back. - Fuzz target: a test that feeds random input to a parser to find crashes.