Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Jakob Bohm <[email protected]> Fri, 17 Mar 2023 14:23:04 +0100
| Newsgroups | sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security |
|---|---|
| Organization | WiseMo A/S |
| Message-ID | <[email protected]> |
On 2023-03-07 07:35, Grant Taylor wrote: > On 3/6/23 6:41 PM, Dennis Boone wrote: >> I'm envisioning something more like some non-host party injecting >> hostile text and control sequences that the host ends up sending to >> some legitimate user. > > Hum. > > If I'm understanding you correctly, say someone manages to post a > message to an echo -- I think that's the term I want -- that contains > hostile control sequences and the terminal user reads said message, > thereby causing their terminal (emulator) to interpret said hostile > control sequences. > > I'm eliding how such hostile control sequences make it that point and > only focusing on an unwitting user accidentally causing the host to send > them. > > > The OP provided a clear and traditional attack path: Entice the OP to read a file by passing it to either cat, stdout of a communications program like PGP, or a non-filtering viewer such as traditional "more" or some implementations of "less -R". Ditto could be done over a traditional teletype remote connection where the OP naively expects a human typing messages from their end, or an honest service providing messages such as "newswires" or weather updates. Note that "less -R and less -r" are mostly useful for viewing files that contain locally controlled and trusted escape sequences for things like color highlighting or sequences of self-overwriting progress bars. Such files would typically come from capturing stdout from some other locally trusted program like git. The easiest way to do safe filtering is to simply drop any bytes in the ranges 0-31, 127-159 and 255 (decimal), as those are control character on various ASCII-derived terminal character sets. If you are certain the terminal is in UTF-8 or CESU-8 mode, instead apply similar filters to the decoded UCS-4 codepoints, then reencode the allowed ones. More sophisticated filtering could recognize the syntax pattern of ECMA-48 CSI sequences, noting the maximum number of parameters and characters per parameter in such sequences. The entire attack category used to be known as an "ANSI Bomb" in reference to the MS-DOS escape sequence handler known as ANSI.SYS I fondly remembering trusted DEC systems using these capabilities to do things like animated login screens on actual DEC VT-xxx terminals. P.S. A Handy reference for popular codes is the Linux manual page console_codes(4). The manpage viewer itself is a good example of providing already trusted input to "less -r" Enjoy Jakob -- Jakob Bohm, CIO, Partner, WiseMo A/S. https://www.wisemo.com Transformervej 29, 2860 Søborg, Denmark. Direct +45 31 13 16 10 This public discussion message is non-binding and may contain errors. WiseMo - Remote Service Management for PCs, Phones and Embedded