I treat links opened from terminal output as a security boundary: OSC8 preserves useful clickable links, but malicious links can disguise where they lead. Ghostty’s approach is to classify URLs and make potentially dangerous ones visible to the user rather than disable OSC8 altogether.
OSC8 is the terminal sequence for linking arbitrary text, similar to a tags in HTML.
I consider OSC8 mandatory for a modern terminal experience, though it is prone to malicious use.
In the next version of Ghostty, we added a classifier for OSC8 URLs—and any hidden URL, really—that assigns each URL the classifications trusted, requires-confirmation, or deny.
Ghostty shows separate requires-confirmation and deny alerts.
Ghostty URL preview changes show hidden characters; direct Unicode interpretation previously allowed maliciously crafted URLs to hide themselves.
Hidden characters immediately trigger the deny classification in Ghostty.
I describe the next version of Ghostty as having the strongest protections for malicious OSC8 short of disabling it entirely.
I describe Ghostty’s OSC8 protections as the strongest, most comprehensive protections for OSC8 across terminals.
I report that Alacritty, Kitty, iTerm2, and WezTerm have OSC8 enabled by default with zero filtering; they can directly open executables or maliciously crafted schemes and hide the real URL through Unicode tricks.
I report that Gnome Terminal enables all OSC8; no configuration I could find to disable; only rejects remote-host file:// URLs; no other sanitization or confirmation.
I describe VS Code Terminal as using an allowlist of safe protocols; prompts for unknown; silently replaces whitespace characters. I call it “Very good!”
I describe Windows Terminal as using an allowlist; prompts for anything executable and for any custom schemes. I call it “Very good!”
I treat terminal parsing as a correctness and safety boundary: escape sequences have syntax whose distinctions matter, and arbitrary external input must not be able to make Ghostty’s core fail. These notes cover SGR parsing edge cases, the libghostty-vt API, and the design of infallible stream processing.
I shared a real-world stress test for anyone who has written or maintains a terminal SGR parser.
Kakoune sends this SGR sequence: \033[;4:3;38;2;175;175;215;58:2::190:80:70m
- The expected parse is unset (0), curly underline (4:3), direct-color foreground (38;2;175;175;215), and underline color (<redacted>).
Ghostty 1.0.1 did not parse Kakoune’s sequence correctly; I said this was fixed on tip.
I emphasized that the colon-versus-semicolon distinction is semantically important and called getting it wrong a mistake.
- The valid color forms I listed were 38;2;R;G;B, 38:2:R:G:B, 38:2:C:R:G:B, 38:2::R:G:B, and 38:2:R:G:B;4.
- The invalid color forms I listed were 38;2;C;R;G;B, 38:2:R:G:B:4, and 38:2:R;G;B, as well as combinations that mix forms.
I exposed SGR parsing through the libghostty C and Wasm API and recommended that users rely on libghostty-vt.
I said almost everyone outside first-party terminals gets SGR parsing wrong, including CI, PaaS, and log viewers, and that quite a few terminals get it wrong too.
I described libghostty-vt as having zero dependencies.
I said libghostty pushes us to improve Ghostty’s core, and that arbitrary external input cannot be trusted and must never cause the core to fail.
Previously, errors could bubble up from handlers to the stream processor, allowing a failed sequence to cause partial processing of terminal sequences; I had never heard of this happening in practice, but the API permitted it.
I made stream processing infallible by requiring handlers to handle errors locally and leave the terminal in a coherent state; the stream processor will move forward.
I used Zig’s error system and type system to make the infallible-processing contract easy to see and enforce.
I concluded that ghostty_terminal_vt_write should have a void return type with zero allocation.
I linked the stream-processing change to its pull request: https://t.co/CArriWoUze.
Related: accessibility and secure input, terminal behavior compatibility, text input and keyboard handling