#2255·miller

Untrusted CSV field values are printed to the terminal without escaping (terminal escape injection)

Author: Syh-XiongCreated Sep 27, 2026Updated Sep 27, 2026

Summary. mlr writes field values verbatim to the terminal. A CSV field containing an ANSI/OSC escape sequence is interpreted by the terminal, allowing e.g. silent clipboard writes (OSC 52), window-title spoofing (OSC 0/2) or screen clearing.

Affected code. pkg/output/record_writer_pprint.go:229 (writeHeterogenousListBarred → WriteString(colorizer.MaybeColorizeValue(s, …))); the same applies to pkg/output/record_writer_csv.go. The colorizer only adds SGR codes and never rewrites the value.

Reproduce:

bash
python3 - <<'PY'
import base64; B64=base64.b64encode(b"TUI-INJECTION-POC").decode()
open("evil.csv","w").write('id,note\n1,"\x1b]52;c;%s\x07"\n' % B64)
PY
mlr --icsv --opprint cat evil.csv | cat -v     # observe ^[]52;c;...

In a terminal supporting OSC 52, ${B64} is written into the clipboard.

Expected. As cat -v does, escape/C0/C1 bytes that are "terminal-active" (ESC, BEL, and the sequences they start) should be replaced (e.g. with ^[, ^G). An opt-out flag could preserve the current behaviour.

Here is my test:

Image

Environment. Ubuntu 22.04.5 LTS (GNU/Linux 6.8.0-124-generic x86_64).