Is it unsafe to concatenate certain terminal escape sequences or ANSI
codes inside a terminal emulator?
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?
Is there potential for malicious escape sequences in the plaintext?
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?
[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.
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.
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.
"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.
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.
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.
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.
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.
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.
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?
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.
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.
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.
"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.
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.
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.
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.
Sysop: | Tetrazocine |
---|---|
Location: | Melbourne, VIC, Australia |
Users: | 4 |
Nodes: | 8 (0 / 8) |
Uptime: | 59:02:19 |
Calls: | 65 |
Files: | 21,500 |
Messages: | 73,556 |