Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If the facts don't fit the theory, change the facts. -- Albert Einstein


computers / alt.bbs / ? Unsafe terminal escape sequences and ANSI codes from decryption

SubjectAuthor
* ? Unsafe terminal escape sequences and ANSI codes from decryptionG.K.
+- Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionGrant Taylor
`* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionRichard
 +* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionG.K.
 |+- Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionG.K.
 |+* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionSimon Tatham
 ||+- [solved] Unsafe terminal escape sequences and ANSI codes fromG.K.
 ||`- Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionPhil Carmody
 |`- Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionRichard
 `* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionDennis Boone
  +* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionGrant Taylor
  |+* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionDennis Boone
  ||`* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionGrant Taylor
  || `* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionDennis Boone
  ||  `* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionGrant Taylor
  ||   `- Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionJakob Bohm
  |`* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionScott Dorsey
  | `* Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionGrant Taylor
  |  `- Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionScott Dorsey
  `- Re: ? Unsafe terminal escape sequences and ANSI codes from decryptionRichard

1
? Unsafe terminal escape sequences and ANSI codes from decryption

<tu1ml1$ti6$1@news.cyber23.de>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292789&group=alt.bbs#292789

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!news.cyber23.de!.POSTED!not-for-mail
From: g...@k.invalid (G.K.)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Sun, 5 Mar 2023 03:19:15 -0600
Organization: Cyber23 news
Message-ID: <tu1ml1$ti6$1@news.cyber23.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 5 Mar 2023 09:16:19 -0000 (UTC)
Injection-Info: news.cyber23.de;
logging-data="30278"; mail-complaints-to="abuse@cyber23.de"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
 by: G.K. - Sun, 5 Mar 2023 09:19 UTC

Is it unsafe to concatenate certain terminal escape sequences or ANSI
codes inside a terminal emulator?

Here is the scenario. I am working from a terminal emulator (lxterm,
gnome-terminal, mate-terminal, guake, terminology). I decrypt a message
to a file. I cat the plaintext file to the terminal ('cat $filename' or
'less -r $filename').

What could go wrong here?

Is there potential for malicious escape sequences in the plaintext?
Could such escape sequences or ANSI codes hijack the terminal and
somehow compromise the system? If so then how?

Where would I find timely information on such escape sequences and
mitigating any problems they could cause or safely filtering them?

What tools are there to filter out such sequences to ensure safely
catting in a terminal? Are there any relevant tools in the GNU coreutils?

--

G.K.

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu2hpe$ule$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292790&group=alt.bbs#292790

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Sun, 5 Mar 2023 09:59:19 -0700
Organization: TNet Consulting
Message-ID: <tu2hpe$ule$1@tncsrv09.home.tnetconsulting.net>
References: <tu1ml1$ti6$1@news.cyber23.de>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 5 Mar 2023 16:59:26 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="31406"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <tu1ml1$ti6$1@news.cyber23.de>
Content-Language: en-US
 by: Grant Taylor - Sun, 5 Mar 2023 16:59 UTC

On 3/5/23 2:19 AM, G.K. wrote:
> Is it unsafe to concatenate certain terminal escape sequences or ANSI
> codes inside a terminal emulator?

I don't think that /concatenating/ terminal escape sequences in and of
itself is unsafe.

That being said, it is possible to have carefully / mischievously
crafted sequences that can appear to hide parts of the sequence and thus
do undesirable things.

Consider the following:

$ echo ; rm -rf /*; echo XXXXXXXXXXXXXXXXXXX the quick brown fox
jumped over the lazy dogs

Where "X" is the escape sequence to move the cursor to the left. Thus
after pasting the sequence you see the following on the command line:

$ echo the quick brown fox jumped over the lazy dogs

In this case the escape sequences are being used to hide multiple
commands (rm and a 2nd echo).

> What could go wrong here?

Outputting raw content can easily mess up the sate of the terminal such
that what's on the screen doesn't match what the system thinks is on the
screen.

I've often seen such output end up ringing the bell (pc speaker beep)
and / or invoke the sequence to cause the terminal (emulator) to send
the answer back one or more times. The answer back actually gets typed
into the input on the new line, so sometimes you need to clear that.

It could be conceivable that there is data on the screen that you want
to retain and don't have elsewhere and the escape sequences clear the
screen and / or the scroll back buffer thereby causing you to loose the
data on the screen.

> Is there potential for malicious escape sequences in the plaintext?

I don't consider the escape sequences themself to be malicious. The use
of them can be malicious.

It also depends on what you consider "plain text" to be. As in what
byte values are allowed.

Then there are files that claim to be plain text which aren't, either
through corruption and / or malicious intention.

> Could such escape sequences or ANSI codes hijack the terminal and
> somehow compromise the system? If so then how?

The escape sequences themselves probably don't have the capability to
compromise the system. However they can be used in combination with
other commands that could be used to compromise something. E.g.
removing files or enabling a vulnerable service or other undesirable
behavior.

> Where would I find timely information on such escape sequences and
> mitigating any problems they could cause or safely filtering them?

The escape sequences themself aren't malicious. Their use may be malicious.

Filtering the escape sequences is going to be a VERY DEEP rabbit hole.
There are a LOT of escape sequences.

If you are truly worried about then, then use a less capable terminal
(emulator) that simply doesn't honor all of the escape sequences.

> What tools are there to filter out such sequences to ensure safely
> catting in a terminal? Are there any relevant tools in the GNU coreutils?

I occasionally look at unknown files with `cat -t` or `xxd` to see a
safe representation of the text to see if there are undesirable use of
escape sequences in them or not.

Remember, escape sequences themselves aren't malicious. What is done
with them may be malicious.

There is also some -- maybe closely -- related topic of copying and
pasting content from the web into a terminal in that malicious actors
have used CSS to hide undesirable commands in the middle of text that is
being copied and pasted. -- Again, the CSS itself isn't malicious.
How it was used is malicious.

Tools -- escape sequences, CSS, knives, cars -- aren't malicious in and
of themselves. How people use them and what they do with them may be
malicious.

--
Grant. . . .
unix || die

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu3qvf$n907$1@news.xmission.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292791&group=alt.bbs#292791

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: legalize...@mail.xmission.com (Richard)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Mon, 6 Mar 2023 04:42:23 -0000 (UTC)
Organization: multi-cellular, biological
Sender: legalize+jeeves@mail.xmission.com
Message-ID: <tu3qvf$n907$1@news.xmission.com>
References: <tu1ml1$ti6$1@news.cyber23.de>
Reply-To: (Richard) legalize+jeeves@mail.xmission.com
Injection-Date: Mon, 6 Mar 2023 04:42:23 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:2607:fa18:0:beef::4";
logging-data="762887"; mail-complaints-to="abuse@xmission.com"
X-Reply-Etiquette: No copy by email, please
Mail-Copies-To: never
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: legalize@shell.xmission.com (Richard)
 by: Richard - Mon, 6 Mar 2023 04:42 UTC

[Please do not mail me a copy of your followup]

"G.K." <g@k.invalid> spake the secret code
<tu1ml1$ti6$1@news.cyber23.de> thusly:

>Is there potential for malicious escape sequences in the plaintext?

For a hardware terminal it is doubtful. The most they could do is
request the contents of the screen be sent to the host or auxiliary
port and not every terminal supports sending screen contents back to
the host.

For a terminal *emulator* it's always possible that they could
identify a vulnerability in the ESC processing code that could lead to
a buffer overflow and the ability to inject bytes into the stack or
heap.

>Where would I find timely information on such escape sequences and
>mitigating any problems they could cause or safely filtering them?

Software vulnerabilities in the emulator would have to be found by
analyzing the source code (or binary code) of the emulator. It's not
intrinsic to the ESC sequences themselves.

>What tools are there to filter out such sequences to ensure safely
>catting in a terminal? Are there any relevant tools in the GNU coreutils?

None AFAIK.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu44aq$1o4r$1@news.cyber23.de>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292792&group=alt.bbs#292792

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!news.cyber23.de!.POSTED!not-for-mail
From: g...@k.invalid (G.K.)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Mon, 6 Mar 2023 01:25:00 -0600
Organization: Cyber23 news
Message-ID: <tu44aq$1o4r$1@news.cyber23.de>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 6 Mar 2023 07:22:03 -0000 (UTC)
Injection-Info: news.cyber23.de;
logging-data="57499"; mail-complaints-to="abuse@cyber23.de"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <tu3qvf$n907$1@news.xmission.com>
 by: G.K. - Mon, 6 Mar 2023 07:25 UTC

On 3/5/23 22:42, Richard wrote:
> [Please do not mail me a copy of your followup]
>
> "G.K." <g@k.invalid> spake the secret code
> <tu1ml1$ti6$1@news.cyber23.de> thusly:
>
>> Is there potential for malicious escape sequences in the plaintext?
>
> For a hardware terminal it is doubtful. The most they could do is
> request the contents of the screen be sent to the host or auxiliary
> port and not every terminal supports sending screen contents back to
> the host.
>
> For a terminal *emulator* it's always possible that they could
> identify a vulnerability in the ESC processing code that could lead to
> a buffer overflow and the ability to inject bytes into the stack or
> heap.
>
>> Where would I find timely information on such escape sequences and
>> mitigating any problems they could cause or safely filtering them?
>
> Software vulnerabilities in the emulator would have to be found by
> analyzing the source code (or binary code) of the emulator. It's not
> intrinsic to the ESC sequences themselves.
>
>> What tools are there to filter out such sequences to ensure safely
>> catting in a terminal? Are there any relevant tools in the GNU coreutils?
>
> None AFAIK.

It looks like I have been greeted by a terminal buff. This may be
fortuitous.

Another distinction occurs to me that might ease the problem
requirement. Is there a cheap way to distinguish between control codes
and formatting codes (color, foreground, background, underline,
blinkenlights) codes in a text stream.

What I mean by 'control codes' are codes for bell, repositioning cursor,
backspace and flush, etc. What I mean by 'formatting codes' is strictly
that which formats the color and appearance without any cursor movement
or flushing on the x and y of the display.

I think this simplifies my problem because it is really the control
codes I would want to watch out for, which could possibly trick someone
visually. That is of course barring some zero day hiding in the source
code of the terminal as you have said.

This would allow concatenating colorized text without stripping all the
color, and I think it would be _relatively_ safe. Some of the messages
being viewed this way would come from unknown persons. I would still
like to be able to view the color and background formatting without any
great risk of exploitation.

Perhaps there is a code that toggles arbitrary escapes off, that could
be injected into the stream, rather than truncating out of the stream.
although I haven't been able to find it.

--

G.K.

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu44ni$1o4s$1@news.cyber23.de>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292793&group=alt.bbs#292793

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!news.cyber23.de!.POSTED!not-for-mail
From: g...@k.invalid (G.K.)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Mon, 6 Mar 2023 01:31:48 -0600
Organization: Cyber23 news
Message-ID: <tu44ni$1o4s$1@news.cyber23.de>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
<tu44aq$1o4r$1@news.cyber23.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 6 Mar 2023 07:28:50 -0000 (UTC)
Injection-Info: news.cyber23.de;
logging-data="57500"; mail-complaints-to="abuse@cyber23.de"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <tu44aq$1o4r$1@news.cyber23.de>
 by: G.K. - Mon, 6 Mar 2023 07:31 UTC

On 3/6/23 01:25, G.K. wrote:
> On 3/5/23 22:42, Richard wrote:
>> [Please do not mail me a copy of your followup]
>>
>> "G.K." <g@k.invalid> spake the secret code
>> <tu1ml1$ti6$1@news.cyber23.de> thusly:
>>
>>> Is there potential for malicious escape sequences in the plaintext?
>>
>> For a hardware terminal it is doubtful.  The most they could do is
>> request the contents of the screen be sent to the host or auxiliary
>> port and not every terminal supports sending screen contents back to
>> the host.
>>
>> For a terminal *emulator* it's always possible that they could
>> identify a vulnerability in the ESC processing code that could lead to
>> a buffer overflow and the ability to inject bytes into the stack or
>> heap.
>>
>>> Where would I find timely information on such escape sequences and
>>> mitigating any problems they could cause or safely filtering them?
>>
>> Software vulnerabilities in the emulator would have to be found by
>> analyzing the source code (or binary code) of the emulator.  It's not
>> intrinsic to the ESC sequences themselves.
>>
>>> What tools are there to filter out such sequences to ensure safely
>>> catting in a terminal? Are there any relevant tools in the GNU
>>> coreutils?
>>
>> None AFAIK.
>
> It looks like I have been greeted by a terminal buff. This may be
> fortuitous.
>
> Another distinction occurs to me that might ease the problem
> requirement. Is there a cheap way to distinguish between control codes
> and formatting codes (color, foreground, background, underline,
> blinkenlights) codes in a text stream.
>
> What I mean by 'control codes' are codes for bell, repositioning cursor,
> backspace and flush, etc. What I mean by 'formatting codes' is strictly
> that which formats the color and appearance without any cursor movement
> or flushing on the x and y of the display.
>
> I think this simplifies my problem because it is really the control
> codes I would want to watch out for, which could possibly trick someone
> visually. That is of course barring some zero day hiding in the source
> code of the terminal as you have said.
>
> This would allow concatenating colorized text without stripping all the
> color, and I think it would be _relatively_ safe. Some of the messages
> being viewed this way would come from unknown persons. I would still
> like to be able to view the color and background formatting without any
> great risk of exploitation.
>
> Perhaps there is a code that toggles arbitrary escapes off, that could
> be injected into the stream, rather than truncating out of the stream.
> although I haven't been able to find it.

I just figured out that 'col' can filter out reverse chars. So now I am
poking around groff, troff, nroff to see if there is any magic hidden in
them.

--

G.K.

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<81zg8q9qiu.fsf@thyestes.tartarus.org>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292794&group=alt.bbs#292794

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!newsfeed.xs3.de!callisto.xs3.de!nntp-feed.chiark.greenend.org.uk!ewrotcd!.POSTED.chiark.greenend.org.uk!not-for-mail
From: ana...@pobox.com (Simon Tatham)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Mon, 06 Mar 2023 09:29:00 +0000
Message-ID: <81zg8q9qiu.fsf@thyestes.tartarus.org>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
<tu44aq$1o4r$1@news.cyber23.de>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: chiark.greenend.org.uk; posting-host="chiark.greenend.org.uk:212.13.197.229";
logging-data="27309"; mail-complaints-to="abuse@chiark.greenend.org.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)
Cancel-Lock: sha1:yrC4uBN7kmhkeGxW4IQKel4X7L0=
Originator: simon@tunnel.thyestes.tartarus.org ([172.31.80.4])
 by: Simon Tatham - Mon, 6 Mar 2023 09:29 UTC

"G.K." <g@k.invalid> writes:
> Another distinction occurs to me that might ease the problem
> requirement. Is there a cheap way to distinguish between control codes
> and formatting codes (color, foreground, background, underline,
> blinkenlights) codes in a text stream.

'less -R' does something along those lines. I don't know if the
filtering code is conveniently separable from the rest of 'less', but
it might be a start: somebody else has already done the work of making a
set of decisions about which codes count in which category.
--
import hashlib; print((lambda p,q,g,y,r,s,m: (lambda w:(pow(g,int(hashlib.sha1(
m.encode('ascii')).hexdigest(),16)*w%q,p)*pow(y,r*w%q,p)%p)%q)(pow(s,q-2,q))==r
and s%q!=0 and m)(12342649995480866419, 2278082317364501, 1670428356600652640,
5398151833726432125, 645223105888478, 1916678356240619, "<anakin@pobox.com>"))

[solved] Unsafe terminal escape sequences and ANSI codes from decryption

<tu4dmn$1rcr$1@news.cyber23.de>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292795&group=alt.bbs#292795

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!news.cyber23.de!.POSTED!not-for-mail
From: g...@k.invalid (G.K.)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: [solved] Unsafe terminal escape sequences and ANSI codes from
decryption
Date: Mon, 6 Mar 2023 04:04:58 -0600
Organization: Cyber23 news
Message-ID: <tu4dmn$1rcr$1@news.cyber23.de>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
<tu44aq$1o4r$1@news.cyber23.de> <81zg8q9qiu.fsf@thyestes.tartarus.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 6 Mar 2023 10:02:00 -0000 (UTC)
Injection-Info: news.cyber23.de;
logging-data="60827"; mail-complaints-to="abuse@cyber23.de"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.8.0
Content-Language: en-US
In-Reply-To: <81zg8q9qiu.fsf@thyestes.tartarus.org>
 by: G.K. - Mon, 6 Mar 2023 10:04 UTC

On 3/6/23 03:29, Simon Tatham wrote:
> "G.K." <g@k.invalid> writes:
>> Another distinction occurs to me that might ease the problem
>> requirement. Is there a cheap way to distinguish between control codes
>> and formatting codes (color, foreground, background, underline,
>> blinkenlights) codes in a text stream.
>
> 'less -R' does something along those lines. I don't know if the
> filtering code is conveniently separable from the rest of 'less', but
> it might be a start: somebody else has already done the work of making a
> set of decisions about which codes count in which category.

This solves the problem. This is a boon and does almost all the work
necessary. From the less manual:

[quote]
-R or --RAW-CONTROL-CHARS
Like -r, but only ANSI "color" escape sequences are output in "raw"
form. Unlike -r, the screen appearance is maintained correctly in most
cases. ANSI "color" escape sequences are sequences of the form:

ESC [ ... m

where the "..." is zero or more color specification characters For the
purpose of keeping track of screen appearance, ANSI color escape
sequences are assumed to not move the cursor. [/quote]

After this I can pipe through a few intelligent line length and UTF-8
validation checks and ship it.

--

G.K.

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu5brv$o0lb$1@news.xmission.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292796&group=alt.bbs#292796

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: legalize...@mail.xmission.com (Richard)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Mon, 6 Mar 2023 18:36:47 -0000 (UTC)
Organization: multi-cellular, biological
Sender: legalize+jeeves@mail.xmission.com
Message-ID: <tu5brv$o0lb$1@news.xmission.com>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com> <tu44aq$1o4r$1@news.cyber23.de>
Reply-To: (Richard) legalize+jeeves@mail.xmission.com
Injection-Date: Mon, 6 Mar 2023 18:36:47 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:2607:fa18:0:beef::4";
logging-data="787115"; mail-complaints-to="abuse@xmission.com"
X-Reply-Etiquette: No copy by email, please
Mail-Copies-To: never
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: legalize@shell.xmission.com (Richard)
 by: Richard - Mon, 6 Mar 2023 18:36 UTC

[Please do not mail me a copy of your followup]

"G.K." <g@k.invalid> spake the secret code
<tu44aq$1o4r$1@news.cyber23.de> thusly:

>Another distinction occurs to me that might ease the problem
>requirement. Is there a cheap way to distinguish between control codes
>and formatting codes (color, foreground, background, underline,
>blinkenlights) codes in a text stream.

The ANSI sequences are described in ECMA-48:
<https://www.ecma-international.org/publications-and-standards/standards/ecma-48/>

Other terminals have their own code sequence, some of which are
documented here:
<https://terminals-wiki.org/wiki/index.php/Category:Code_Chart>. You
can also reverse engineer them from the terminfo/termcap database.
<https://invisible-island.net/ncurses/#download_database>

>What I mean by 'control codes' are codes for bell, repositioning cursor,
>backspace and flush, etc. What I mean by 'formatting codes' is strictly
>that which formats the color and appearance without any cursor movement
>or flushing on the x and y of the display.

For ANSI sequences, this is well defined. For other terminal types,
it depends on their control sequences which are usually documented in
the manual accompanying the terminal. There are a very few fancy
terminals which allowed you to download firmware directly into the
terminal which potentially means for arbitrary control sequences.
However, these terminals were not common (AFAIK) and are unlikely to
be targetted in random control sequence streams you'd encounter on the
net. It was not uncommon for OEM manufacturers to allow custom ROMs
to be installed in order to support custom control sequences.

If you want to understand the inner workings of how a hardware
terminal typically processes the incoming byte stream, I can point you
to more resources that explain it in detail.

>I think this simplifies my problem because it is really the control
>codes I would want to watch out for, which could possibly trick someone
>visually. That is of course barring some zero day hiding in the source
>code of the terminal as you have said.

Terminal *emulator*, not terminal.

>Perhaps there is a code that toggles arbitrary escapes off, that could
>be injected into the stream, rather than truncating out of the stream.
>although I haven't been able to find it.

There is no such thing for ANSI control sequences (look at the ECMA-48
link above) and in all the other oddball terminals I've looked at,
they don't have this either. There would be no point in having this
because the whole point of a smart terminal is for it to understand
and process commands in the communication stream.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292797&group=alt.bbs#292797

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Mon, 06 Mar 2023 22:29:01 +0000
Sender: Dennis Boone <drb@yagi.h-net.org>
From: drb...@ihatespam.msu.edu (Dennis Boone)
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
User-Agent: tin/2.6.1-20211226 ("Convalmore") (FreeBSD/13.1-RELEASE-p2 (amd64))
Message-ID: <WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com>
Date: Mon, 06 Mar 2023 22:29:01 +0000
Lines: 17
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-yeh80k2iM9Q80dA4V68e+TNlnC0zzxMTUg6ME8FTMrTROA6LMI0uuLgyUCLeDH2EEMMzi+k3pDQW3de!MYu4IsXK5YEibzSJ+NjCaTkL1t0GxWgcMkHSVrm0r267vmz42ZSWNaGPfy0gB7bCrPNO+zo=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Dennis Boone - Mon, 6 Mar 2023 22:29 UTC

> For a hardware terminal it is doubtful. The most they could do is
> request the contents of the screen be sent to the host or auxiliary
> port and not every terminal supports sending screen contents back to
> the host.

Actually, one might be able to program an answerback sequence that e.g.
contained a hostile command, then triggered the terminal to send said
command. Depending on how the particular model implements screen
content send, it might be possible to inject malicious commands via that
path too.

There are other forms of objectionable behavior. In some environments,
causing the terminal to make a lot of noise, for example, could be an
issue. Send your real VT100 the sequence "ESC [ 1 4 5 q" in such a
place, and the enjoy the panic of figuring out how to stop it.

De

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu602l$3b9$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292798&group=alt.bbs#292798

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Mon, 6 Mar 2023 17:21:33 -0700
Organization: TNet Consulting
Message-ID: <tu602l$3b9$1@tncsrv09.home.tnetconsulting.net>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
<WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 7 Mar 2023 00:21:41 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="3433"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com>
Content-Language: en-US
 by: Grant Taylor - Tue, 7 Mar 2023 00:21 UTC

On 3/6/23 3:29 PM, Dennis Boone wrote:
> Actually, one might be able to program an answerback sequence that e.g.
> contained a hostile command, then triggered the terminal to send
> said command. Depending on how the particular model implements screen
> content send, it might be possible to inject malicious commands via
> that path too.

Please walk me through this hypothetical scenario.

My main holdup is that I thought configuring the answerback was purely
client side. Is there some terminal (emulator) that can be caused to
alter it's answerback setting via control codes sent to it by the remote
system?

I would have thought that a local user would maliciously configure their
terminal (emulator) to send a suspicious answerback if / when prompted.

> There are other forms of objectionable behavior. In some environments,
> causing the terminal to make a lot of noise, for example, could be
> an issue. Send your real VT100 the sequence "ESC [ 1 4 5 q" in such
> a place, and the enjoy the panic of figuring out how to stop it.

Especially with buffer on one end and / or the other end.

--
Grant. . . .
unix || die

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<EgOdnW4SMPJQG5v5nZ2dnZfqnPWdnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292799&group=alt.bbs#292799

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!news.misty.com!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 07 Mar 2023 00:35:25 +0000
Sender: Dennis Boone <drb@yagi.h-net.org>
From: drb...@ihatespam.msu.edu (Dennis Boone)
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com> <WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com> <tu602l$3b9$1@tncsrv09.home.tnetconsulting.net>
User-Agent: tin/2.6.1-20211226 ("Convalmore") (FreeBSD/13.1-RELEASE-p2 (amd64))
Message-ID: <EgOdnW4SMPJQG5v5nZ2dnZfqnPWdnZ2d@giganews.com>
Date: Tue, 07 Mar 2023 00:35:25 +0000
Lines: 17
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-xCO1wfWyphpEtDmPkKhXpw4AmTm0KrJGDCWA6BREHivEDw3K3tB4+bZJ4lprbYN7qtmeb5HFaT3C08n!8IJSYc7Yn3BYL3nxzWi9R+ope1SNWK4qCWHfANobLx5ncD0UBL/s8gl1tsMJR4F1muan/z4=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Dennis Boone - Tue, 7 Mar 2023 00:35 UTC

> My main holdup is that I thought configuring the answerback was purely
> client side. Is there some terminal (emulator) that can be caused to
> alter it's answerback setting via control codes sent to it by the remote
> system?

I'm pretty sure I've seen terminals where you can set it remotely, but I
can't point to evidence off the top.

But that's just one scenario. Aggravating factors might include:

- Even if you can't load answerback, you might be able to load
programmable function keys, and then entice the user to press one.

- The emulation of VT100 or similar gives one of the most powerful
command sets.

De

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu63f4$ck2$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292800&group=alt.bbs#292800

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Mon, 6 Mar 2023 18:19:24 -0700
Organization: TNet Consulting
Message-ID: <tu63f4$ck2$1@tncsrv09.home.tnetconsulting.net>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
<WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com>
<tu602l$3b9$1@tncsrv09.home.tnetconsulting.net>
<EgOdnW4SMPJQG5v5nZ2dnZfqnPWdnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 7 Mar 2023 01:19:32 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="12930"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <EgOdnW4SMPJQG5v5nZ2dnZfqnPWdnZ2d@giganews.com>
Content-Language: en-US
 by: Grant Taylor - Tue, 7 Mar 2023 01:19 UTC

On 3/6/23 5:35 PM, Dennis Boone wrote:
> I'm pretty sure I've seen terminals where you can set it remotely,
> but I can't point to evidence off the top.

ACK

> But that's just one scenario. Aggravating factors might include:
>
> - Even if you can't load answerback, you might be able to load
> programmable function keys, and then entice the user to press one.
>
> - The emulation of VT100 or similar gives one of the most powerful
> command sets.

Fair enough.

I think the other big thing that I'm struggling with is the fact that in
a nominally two party system, the host and the terminal (emulator), the
host would be making the terminal (emulator) attack the host. And
nominally be enticing the user of the terminal (emulator) to take action.

With this in mind, I'm not seeing the actual attack vector / scenario.

Could things be done, maybe. But what would it accomplish that the host
didn't already have?

--
Grant. . . .
unix || die

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<9KqdnbC-6MvWC5v5nZ2dnZfqn_SdnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292801&group=alt.bbs#292801

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!69.80.99.27.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 07 Mar 2023 01:41:31 +0000
Sender: Dennis Boone <drb@yagi.h-net.org>
From: drb...@ihatespam.msu.edu (Dennis Boone)
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com> <WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com> <tu602l$3b9$1@tncsrv09.home.tnetconsulting.net> <EgOdnW4SMPJQG5v5nZ2dnZfqnPWdnZ2d@giganews.com> <tu63f4$ck2$1@tncsrv09.home.tnetconsulting.net>
User-Agent: tin/2.6.1-20211226 ("Convalmore") (FreeBSD/13.1-RELEASE-p2 (amd64))
Message-ID: <9KqdnbC-6MvWC5v5nZ2dnZfqn_SdnZ2d@giganews.com>
Date: Tue, 07 Mar 2023 01:41:31 +0000
Lines: 10
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-Dl9PkICfEyq2Trc/LYwrhkfWzQ8+wPh+l7BP04ONDvndmC/J69Td963s2AOhtPY45CGwQiPvgEpb3NK!nnRXEjmRFY5kif+rVaR7hEYswVTzTiZEY2kBWPof4XXbS5t2lqL1ke+AK98V+2oCGeVa2SM=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 1916
 by: Dennis Boone - Tue, 7 Mar 2023 01:41 UTC

> I think the other big thing that I'm struggling with is the fact that in
> a nominally two party system, the host and the terminal (emulator), the
> host would be making the terminal (emulator) attack the host. And
> nominally be enticing the user of the terminal (emulator) to take action.

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.

De

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu6752$sb8$1@panix2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292802&group=alt.bbs#292802

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix2.panix.com!panix2.panix.com!not-for-mail
From: klu...@panix.com (Scott Dorsey)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: 7 Mar 2023 02:22:26 -0000
Organization: Former users of Netcom shell (1989-2000)
Lines: 31
Message-ID: <tu6752$sb8$1@panix2.panix.com>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com> <WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com> <tu602l$3b9$1@tncsrv09.home.tnetconsulting.net>
Injection-Info: reader2.panix.com; posting-host="panix2.panix.com:166.84.1.2";
logging-data="14223"; mail-complaints-to="abuse@panix.com"
 by: Scott Dorsey - Tue, 7 Mar 2023 02:22 UTC

Grant Taylor <gtaylor@tnetconsulting.net> wrote:
>On 3/6/23 3:29 PM, Dennis Boone wrote:
>> Actually, one might be able to program an answerback sequence that e.g.
>> contained a hostile command, then triggered the terminal to send
>> said command. Depending on how the particular model implements screen
>> content send, it might be possible to inject malicious commands via
>> that path too.
>
>Please walk me through this hypothetical scenario.
>
>My main holdup is that I thought configuring the answerback was purely
>client side. Is there some terminal (emulator) that can be caused to
>alter it's answerback setting via control codes sent to it by the remote
>system?

The HP space helmet terminals (HP2626A, HP2645, etc) would do that. They
also would allow you to program a function key to send a sequence, then
send a code to make all following text black-on-black, and then send a
code to press that function key. Great fun in student labs with the
HP/3000.

There also was a thing on the CDC 721 terminal where you could send a
sequence to copy the scrollback buffer into a second screen memory,
so after the person cleared the terminal you could go back and see
their session text including the login password by going through menus
to display the buffer. A friend of mine used this to great effect
at the registration office when he was a student.
--scott

--
"C'est un Nagra. C'est suisse, et tres, tres precis."

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu6ij3$okri$1@news.xmission.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292804&group=alt.bbs#292804

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: legalize...@mail.xmission.com (Richard)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Tue, 7 Mar 2023 05:37:39 -0000 (UTC)
Organization: multi-cellular, biological
Sender: legalize+jeeves@mail.xmission.com
Message-ID: <tu6ij3$okri$1@news.xmission.com>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com> <WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com>
Reply-To: (Richard) legalize+jeeves@mail.xmission.com
Injection-Date: Tue, 7 Mar 2023 05:37:39 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:2607:fa18:0:beef::4";
logging-data="807794"; mail-complaints-to="abuse@xmission.com"
X-Reply-Etiquette: No copy by email, please
Mail-Copies-To: never
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: legalize@shell.xmission.com (Richard)
 by: Richard - Tue, 7 Mar 2023 05:37 UTC

[Please do not mail me a copy of your followup]

drb@ihatespam.msu.edu (Dennis Boone) spake the secret code
<WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com> thusly:

> > For a hardware terminal it is doubtful. The most they could do is
> > request the contents of the screen be sent to the host or auxiliary
> > port and not every terminal supports sending screen contents back to
> > the host.
>
>Actually, one might be able to program an answerback sequence that e.g.
>contained a hostile command, then triggered the terminal to send said
>command.

Good point, but most real terminals don't have much space for the
answerback message. In the VT100 it's 20 characters. In the VT320
it is 30 characters. Enough to contain a whole command, but not
anything huge.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu6m0i$ojs$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292805&group=alt.bbs#292805

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Mon, 6 Mar 2023 23:35:53 -0700
Organization: TNet Consulting
Message-ID: <tu6m0i$ojs$1@tncsrv09.home.tnetconsulting.net>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
<WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com>
<tu602l$3b9$1@tncsrv09.home.tnetconsulting.net>
<EgOdnW4SMPJQG5v5nZ2dnZfqnPWdnZ2d@giganews.com>
<tu63f4$ck2$1@tncsrv09.home.tnetconsulting.net>
<9KqdnbC-6MvWC5v5nZ2dnZfqn_SdnZ2d@giganews.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 7 Mar 2023 06:36:02 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="25212"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <9KqdnbC-6MvWC5v5nZ2dnZfqn_SdnZ2d@giganews.com>
Content-Language: en-US
 by: Grant Taylor - Tue, 7 Mar 2023 06:35 UTC

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.

--
Grant. . . .
unix || die

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tu6mkj$g01$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292806&group=alt.bbs#292806

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Mon, 6 Mar 2023 23:46:35 -0700
Organization: TNet Consulting
Message-ID: <tu6mkj$g01$1@tncsrv09.home.tnetconsulting.net>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
<WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com>
<tu602l$3b9$1@tncsrv09.home.tnetconsulting.net>
<tu6752$sb8$1@panix2.panix.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 7 Mar 2023 06:46:43 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="16385"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <tu6752$sb8$1@panix2.panix.com>
Content-Language: en-US
 by: Grant Taylor - Tue, 7 Mar 2023 06:46 UTC

On 3/6/23 7:22 PM, Scott Dorsey wrote:
> The HP space helmet terminals (HP2626A, HP2645, etc) would do that.

Interesting. Thank you for sharing Scott. Today I learned something. :-)

> They also would allow you to program a function key to send a sequence,
> then send a code to make all following text black-on-black, and then
> send a code to press that function key. Great fun in student labs
> with the HP/3000.

Ya, I can see how re-programming a function key has some value. I don't
know if that's as security sensitive as something like the answer back.

Aside: I know, don't ever trust something that an end user provides for
a security decision. But I've heard of answerback being used as a
terminal identification (along with the port that it's connected to) and
such information influencing other aspects of the system.

Further aside: I use the answerback capability of my two primary
terminal emulators; XTerm and iTerm2, as a way to identify the client
that I'm on to the host. It's nice to have as I SSH through multiple
systems. I can tweak creature features like title bar updates and the
likes based on known client terminal emulators.

> There also was a thing on the CDC 721 terminal where you could send a
> sequence to copy the scrollback buffer into a second screen memory,
> so after the person cleared the terminal you could go back and see
> their session text including the login password by going through
> menus to display the buffer. A friend of mine used this to great
> effect at the registration office when he was a student.

Interesting.

It seems like both of these attacks could relatively easily be defended
against -- as long as you knew to do so -- in that you could re-program
the terminal to behave correctly /and/ to clear the second screen memory.

For a few minutes I thought you were going to suggest something to have
the terminal copy screen contents and feed it back to the host in a way
that didn't echo on the host.

--
Grant. . . .
unix || die

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<87fsahdnd7.fsf@zotaspaz.fatphil.org>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292807&group=alt.bbs#292807

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: pc+use...@asdf.org (Phil Carmody)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: Tue, 07 Mar 2023 09:36:20 +0200
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <87fsahdnd7.fsf@zotaspaz.fatphil.org>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com>
<tu44aq$1o4r$1@news.cyber23.de> <81zg8q9qiu.fsf@thyestes.tartarus.org>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="6521207fbc2484ddfb28f23b4f1f8d1e";
logging-data="358679"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX193PecrWnsY7AiJG8bgYxOE"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)
Cancel-Lock: sha1:tm+KZGEiVuLUK6UAZTa2KiaEg3g=
sha1:0mooC/Psb6zYWP8G979b0jTQreQ=
 by: Phil Carmody - Tue, 7 Mar 2023 07:36 UTC

Simon Tatham <anakin@pobox.com> writes:
> "G.K." <g@k.invalid> writes:
>> Another distinction occurs to me that might ease the problem
>> requirement. Is there a cheap way to distinguish between control codes
>> and formatting codes (color, foreground, background, underline,
>> blinkenlights) codes in a text stream.
>
> 'less -R' does something along those lines. I don't know if the
> filtering code is conveniently separable from the rest of 'less', but
> it might be a start: somebody else has already done the work of making a
> set of decisions about which codes count in which category.

Anything the source thinks should be displayed in black on black should
not be trusted. Therefore you should prefer ``-r or --raw-control-chars''
to ``-R or --RAW-CONTROL-CHARS''.

Phil
--
We are no longer hunters and nomads. No longer awed and frightened, as we have
gained some understanding of the world in which we live. As such, we can cast
aside childish remnants from the dawn of our civilization.
-- NotSanguine on SoylentNews, after Eugen Weber in /The Western Tradition/

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<tuaspu$eqh$1@panix2.panix.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292811&group=alt.bbs#292811

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix2.panix.com!panix2.panix.com!not-for-mail
From: klu...@panix.com (Scott Dorsey)
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Date: 8 Mar 2023 20:56:30 -0000
Organization: Former users of Netcom shell (1989-2000)
Lines: 33
Message-ID: <tuaspu$eqh$1@panix2.panix.com>
References: <tu1ml1$ti6$1@news.cyber23.de> <tu602l$3b9$1@tncsrv09.home.tnetconsulting.net> <tu6752$sb8$1@panix2.panix.com> <tu6mkj$g01$1@tncsrv09.home.tnetconsulting.net>
Injection-Info: reader2.panix.com; posting-host="panix2.panix.com:166.84.1.2";
logging-data="8432"; mail-complaints-to="abuse@panix.com"
 by: Scott Dorsey - Wed, 8 Mar 2023 20:56 UTC

Grant Taylor <gtaylor@tnetconsulting.net> wrote:
>On 3/6/23 7:22 PM, Scott Dorsey wrote:
>
>> There also was a thing on the CDC 721 terminal where you could send a
>> sequence to copy the scrollback buffer into a second screen memory,
>> so after the person cleared the terminal you could go back and see
>> their session text including the login password by going through
>> menus to display the buffer. A friend of mine used this to great
>> effect at the registration office when he was a student.
>
>Interesting.
>
>It seems like both of these attacks could relatively easily be defended
>against -- as long as you knew to do so -- in that you could re-program
>the terminal to behave correctly /and/ to clear the second screen memory.

Yes. The CDC 721 attack required physical access to the terminal and it
required the terminal to remain powered on before the attacker got to it.
Which is typically easy in an open terminal cluster but could be defeated
by turning the terminal off after using it.

>For a few minutes I thought you were going to suggest something to have
>the terminal copy screen contents and feed it back to the host in a way
>that didn't echo on the host.

There might be a way to do that, I don't know. The HP terminals have so
many crazy modes for local forms management and multidrop connections and
so forth that there could be all kinds of hidden vulnerabilities in there.

ANSI terminals are so much more sane than some of the stuff we had out there.
--scott
--
"C'est un Nagra. C'est suisse, et tres, tres precis."

Re: ? Unsafe terminal escape sequences and ANSI codes from decryption

<3rGdnde40_TK9In5nZ2dnZeNn_pi4p2d@giganews.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=292813&group=alt.bbs#292813

  copy link   Newsgroups: sci.crypt alt.security.pgp alt.bbs comp.terminals alt.computer.security
Path: i2pn2.org!rocksolid2!news.neodome.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.15.MISMATCH!border-1.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Fri, 17 Mar 2023 13:21:27 +0000
Subject: Re: ? Unsafe terminal escape sequences and ANSI codes from decryption
Newsgroups: sci.crypt,alt.security.pgp,alt.bbs,comp.terminals,alt.computer.security
References: <tu1ml1$ti6$1@news.cyber23.de> <tu3qvf$n907$1@news.xmission.com> <WnqdnaEQAqGw9Jv5nZ2dnZfqn_adnZ2d@giganews.com> <tu602l$3b9$1@tncsrv09.home.tnetconsulting.net> <EgOdnW4SMPJQG5v5nZ2dnZfqnPWdnZ2d@giganews.com> <tu63f4$ck2$1@tncsrv09.home.tnetconsulting.net> <9KqdnbC-6MvWC5v5nZ2dnZfqn_SdnZ2d@giganews.com> <tu6m0i$ojs$1@tncsrv09.home.tnetconsulting.net>
From: jb-use...@wisemo.com.invalid (Jakob Bohm)
Organization: WiseMo A/S
Date: Fri, 17 Mar 2023 14:23:04 +0100
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:5.2) Goanna/20221030 Epyrus/2.0.0
MIME-Version: 1.0
In-Reply-To: <tu6m0i$ojs$1@tncsrv09.home.tnetconsulting.net>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Message-ID: <3rGdnde40_TK9In5nZ2dnZeNn_pi4p2d@giganews.com>
Lines: 64
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-phQeb18DBjBjbBJL5F1hQiNd6DIefilKcOsQTU/JdFNHiQaba7D7Og09T2RIkO6zg1c0qUF7bEQpdfQ!OnBnD7dNtjRYhtId3kMpkgGdY4QgEFVQu93vZ5cR5qIPIkdESq/FnlaP60S/L47HbQhARp30w7A=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 4628
 by: Jakob Bohm - Fri, 17 Mar 2023 13:23 UTC

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

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor