tirith protects against several classes of terminal-based attacks by applying specific security policies to pasted content:
Terminal Escape and Control Character Attacks
Any control character other than \n (newline) and \t (tab) is BLOCK by default. Any ANSI escape sequence is BLOCK by default. This prevents:
- ANSI escape injection: Rewriting displayed text to hide malicious commands.
- Carriage return (
\r) tricks: Forcing immediate submission or overwriting visible text. - Backspace (
\b) tricks: Visually overwriting characters while keeping the malicious bytes in the buffer. - Unicode bidi override: Using RTL/LTR characters (e.g.,
U+202E) to flip display order. - Zero-width characters: Using ZWJ, ZWNJ, or zero-width spaces to create visually deceptive domains/paths.
Source-Sink Execution Model
tirith identifies risks by modeling commands as a graph of sources (fetching remote content) and sinks (executing content). A connection between a source and a sink triggers a warning.
Sources include: curl, wget, fetch, aria2c, httpie, git clone/pull, docker pull/build, scp, rsync, nc, ncat, socat, and language-specific fetchers (e.g., python -c "import urllib...").
Sinks include: Shells (sh, bash, zsh, fish, etc.), interpreters (python, node, perl, ruby, php), and execution primitives (eval, exec, source, ., sudo sh, xargs sh -c).
PowerShell specific mappings:
- Sources:
Invoke-WebRequest (iwr), Invoke-RestMethod (irm), wget (alias), curl (alias). - Sinks:
Invoke-Expression (iex), & (call operator), Start-Process, powershell -Command.