Re:The Terminal Escape Sequences Ocean Is Deep and Dark
by pdw on Wednesday January 18, 2023 @03:09AM
(#34424499)
The more serious issue is that this library apparently does not enforce a length limit on escape sequences.
[ Parent
| on HN ]
Re:The Terminal Escape Sequences Ocean Is Deep and Dark
by rwmj on Wednesday January 18, 2023 @05:20AM
(#34425168)
It seems to have a hand-written ad hoc parser, handling untrusted input. A very rich source of exploits. (Luckily it's at least using a memory safe language so what you can do is likely limited to DoSing yourself or using up all memory as in this case.)
Re:The Terminal Escape Sequences Ocean Is Deep and Dark
by EthanHeilman on Wednesday January 18, 2023 @07:00AM
(#34425708)
I know this sounds sarcastic, but I don't mean it that way. Are there virtual terminals which are not hand-written ad hoc parsers?
Re:The Terminal Escape Sequences Ocean Is Deep and Dark
by yencabulator on Thursday January 19, 2023 @04:24PM
(#34445817)
They seem to be using this library for some sort of remote shell session snooping. At the very least this sort of negligence lets an attacker smuggle commands through the system unnoticed.
Re:The Terminal Escape Sequences Ocean Is Deep and Dark
by EthanHeilman on Wednesday January 18, 2023 @06:53AM
(#34425673)
An assumption made by many virtual terminals is that the input and output stream are trusted. For instance `cat file.txt` in a terminal result in your terminal being sent escape sequences that will change how your terminal functions well after you quit cat.
I've always wanted a virtual terminal that had a terminal state stack, when you run a command or open a program, all the changes to the terminal are pushed on the top of terminal stack. When I quit the program or the command stops, the state is popped. It seems like it would be very difficult to implement such a thing in the current terminal framework because as far as I can tell, they do not understand when a command starts or stops. Then again the effectiveness of virtual terminals over the last 5 or so decades is likely because of this simplicity and its corresponding flexibility.
Re:The Terminal Escape Sequences Ocean Is Deep and Dark
by kps on Wednesday January 18, 2023 @03:51PM
(#34432908)
A few terminals (e.g. iTerm2) try to track the current command, presumably by looking at the children of the shell they spawn. This isn't much use when your current command is `ssh`.
You could probably have a push/pop escape sequence requiring a matching unique token that intermediate output can't guess.
OSC 57473 ; 1 ; <token> ST
⋮
OSC 57473 ; 0 ; <token> ST
Re:The Terminal Escape Sequences Ocean Is Deep and Dark
by EthanHeilman on Thursday January 19, 2023 @08:30AM
(#34440033)
Can bash do this? I wonder what issue I have yet to think of prevents pop/pushing escape sequences from being default behavior.
Re:The Terminal Escape Sequences Ocean Is Deep and Dark
by kps on Thursday January 19, 2023 @09:09AM
(#34440409)
I think with most current shells you could do this in prompt strings. Actually, you'd probably want a combo that restores the top-of-stack state and leaves it there; then you'd push the state during shell initialization and restore it in the prompt.