fix: no escape sequences from agent text, files or config reach the terminal
Problem
A security review found several ways for text vigent displays to reach the terminal as live escape sequences, mostly in the TypeScript build. Its final row writer (oneRow) keeps ESC, BEL and C1 characters for vigent's own styling, so anything that skipped printable() went out raw. Reproduced with fake CLIs in a PTY:
:diffand:reviewdrew file contents raw, so a file could write the clipboard (OSC 52) or retitle the window when opened.- The Claude Code permission prompt's title drew the denied command raw.
- "Always allow" saved rules the picker had cut off with "…", in both builds.
printable()kept agent-supplied OSC 8 links, with labels that differ from their targets and any URL scheme. C1 characters inside them could break out on some terminals.- Model names reported by a CLI, and some config strings (
[style.icons],user_label), were drawn raw. - Markdown links in table cells hid their target, in both builds.
vigent add,vigent searchand--listprinted registry text raw, in both builds.
The Rust build draws through ratatui, which drops control characters, so most of these affect only the TypeScript build.
Change
Each leak is fixed where the text comes in. "Always allow" shows every rule it saves and refuses wildcard rules. Details follow as the commits land.
Status
Draft. In progress; the full checks run before this leaves draft.
Verification
To be filled in: a test per sink in both languages, and a pty test on both builds that checks no OSC 52, OSC 0, CSI erase or C1 bytes reach the terminal.
Follow-ups
None yet.
Generated by Claude Code
Summary by cubic
Hardens terminal output so agent text, file contents, and config strings can no longer reach the terminal as live escape sequences.
printable()no longer keeps agent-supplied OSC 8 links: link text stays but the link is dropped, so a link can't showhttps://github.comwhile openingfile:///etc/passwd. C1 (U+0080–U+009F) and bidi controls are stripped, SGR conceal is removed, and other colors keep working.:diffand:reviewdraw a file's escape sequences as visible text (\x1b]52;…) instead of sending them, covering unified and side-by-side layouts, hunk headers, and file names in both builds.- The permission prompt shows the refused command written out, and lists each refused call and every rule it would save in full. Rules come from the command with its escape sequences removed; a command whose programs can't all be named gets no rule, so "always allow" can't save a bare
Bashthat allows every command. - Model names a CLI reports (init events, Codex's
debug models, pi's--list-models) are read throughoneLine; a name left with nothing keeps the previous one, and a Codex slug that's only escapes is dropped. - Adds
plainText,oneLine,escapeControls, andfileTexthelpers for plain-terminal output, plus hostile-text tests for each sink.