Live data from Hacker News

"cat readme.txt" is not safe if you use iTerm2

blog.calif.io

51–60 of 197 posts

Re: "cat readme.txt" is not safe if you use iTerm2

#51
There's been plenty of times that I catted a binary file and broke my terminal settings. Sometimes fixable by running `clear` (without being able to see what I'm typing), sometimes not.

And I know PuTTY has a setting for what string is returned in response to some control code, that iirc per standard can be set from some other code.

.

In general, in-band signaling allows for "fun" tricks.

.

+++

Re: "cat readme.txt" is not safe if you use iTerm2

#52
> A terminal used to be a real hardware device: a keyboard and screen connected to a machine, with programs reading input from that device and writing output back to it.

> A terminal emulator like iTerm2 is the modern software version of that hardware terminal.

That's the fundamental fatal flaw of emulating a bad dead hardware design. Are there any attempts to evolve here past all these weird in-band escape sequences leading cats to scratch your face?

Re: "cat readme.txt" is not safe if you use iTerm2

#54

Back in the PDP-10 days, one communicated with it using a terminal attached to it. One of my fellow students discovered that if you hit backspace enough times, the terminal handler would keep erasing characters before the buffer. Go far enough, and then there was an escape character (Ctrl-u?) that would delete the whole line. Poof went the operating system!

control+u for line-kill is probably a recent thing, a random PDF of "The Unix Programming Environment" (Kernighan & Pike, 1984, p.6) has @ as the line-kill character (and # is erase which these days may or may not be control+? (linux often does something wrong with the delete key, unlike the *BSD)).

Re: "cat readme.txt" is not safe if you use iTerm2

#55
post #52

> A terminal used to be a real hardware device: a keyboard and screen connected to a machine, with programs reading input from that device and writing output back to it. > A terminal emulator like iTerm2 is the modern software version of that hardware terminal. That's the fundamental fatal flaw of emulating a bad dead hardware design. Are there any attempts to evolve here past all these weird in-band escape sequences…

Yes. It’s called the X Window System and it’s been around since the ‘80s.

Also the problem here isn’t that iterm2 is trying to emulate terminals, it’s that it’s trying to do something more over the same network connection without making changes to the ssh protocol.

Re: "cat readme.txt" is not safe if you use iTerm2

#56
post #21

Earlier quoted context omitted.

Not sure if that's a great example. If there's a catastrophic vulnerability in a widely used tool, I'd sure like to know about it even if the patch is taking some time! The problem with this is that the credible information "there's a bug in widely used tool x" will soon (if not already) be enough to trigger massive token expenditure of various others that will then also discover the bug, so this will often effective…

>there's a bug in widely used tool x" There's a security bug in Openssh. I don't know what it is, but I can tell you with statistical certainty that it exists. Go on and do with this information whatever you want.

I think in the context of these it’s more of “we’ve discovered a bug” which gives you more information than “there is a bug”. The main difference in information being that the former implies not only there is a bug but that LLMs can find it.

Re: "cat readme.txt" is not safe if you use iTerm2

#57

Back in the PDP-10 days, one communicated with it using a terminal attached to it. One of my fellow students discovered that if you hit backspace enough times, the terminal handler would keep erasing characters before the buffer. Go far enough, and then there was an escape character (Ctrl-u?) that would delete the whole line. Poof went the operating system!

[flagged]

Re: "cat readme.txt" is not safe if you use iTerm2

#58
post #18
post #10

Earlier quoted context omitted.

I think the problem is that 1) You want to be able to write arbitrary bytes, including shell escape sequences into files. 2) You don't want to accidentally write terminal escape sequences to stdout. 3) Stdout is modeled as a file. Consider cat. It's short for concatenate. It concatenates the files based to it as arguments and writes them to stdout, that may or may not be redirected to a file. If it didn't pass along…

> that may or may not be redirected to a file This is usually knowable. It's a different question whether cat should be doing that, though – it's an extremely low level tool. What's wrong with `less`? (Other than the fact that some Docker images seem to not include it, which is pretty annoying and raises the question as to whether `docker exec` should be filtering escape sequences...)

Besides less having a lot of code (features, bloat) and therefore attack surface (some less honor LESSSECURE=1 which on some OS these days involves some pretty tight pledge(2) restrictions), or that some vendors have configured less by default to automatically run random code so you can automatically page a gziped file or an attacker can maybe run arbitrary code (whoops!). Besides those issues, and any others I do not know about? Nothing.

Re: "cat readme.txt" is not safe if you use iTerm2

#59
post #8

More like iTerm2 is not safe

A long, long time ago, it was literally possible to stuff the command buffer of a “dumb terminal” using ESC sequences and spoof keyboard input. So yeah, don’t count on ’cat’ being safe if your terminal isn’t!

> and spoof keyboard input

That's because we had terminal side macros. They were awesome in the 1980s.

Re: "cat readme.txt" is not safe if you use iTerm2

#60
post #48

I’ve said this for as long as I’ve been here on hacker news… I want the terminal to be as dumb as possible. I don’t want it to have any understanding of what it is displaying or anscribe any meaning or significance to the character characters it is outputting. The first time apples terminal.app displayed that little lock icon at the ssh password prompt? The hairs on the back of your neck should have stood up.

What you’re describing would be a completely unusable terminal. You’d lose things as basic as the backspace key. And what’s wrong with Terminal.app indicating when it’s suppressing output?
Post reply on HN