News for hackers. Stuff that matters.
Re:Curl Wttr.in by teddyh on Friday June 26, 2020 @03:30AM (#23649620)
I will take this opportunity to offer some caution:

From what I understand, “curl example.com” is almost exactly as risky as “curl example.com | bash”, since curl does not escape terminal command sequences, and those can include key rebindings; e.g. your Enter key can be rebound to “rm -rf ∗” or “sendfile ∗ [email protected]”.

Re:Curl Wttr.in by igor_chubin on Friday June 26, 2020 @04:33AM (#23649918)
It was the case indeed (many many years ago), we discussed at the anuualy curl hackers conference in Nuremberg back in 2017, but the only terminals that we managed to find with the support of this were not younger than 2001.

Anyway, one can write a small filter, to cut any suspicious sequences from the output off, and add some wrapper like that to your bashrc:

curl() { [ -t 1 ] && curl "$@" | sanitize || curl "$@"; }

Re:Curl Wttr.in by rsapkf on Friday June 26, 2020 @08:24AM (#23651187)
I see you are using regular formatting for code/shell commands on your comments. Not that that's a problem but just a note you can use one of HN's comments formatting tips[0] for this.

Text after a blank line that is indented by two or more spaces is reproduced verbatim. (This is intended for code.)

[0]: https://news.ycombinator.com/formatdoc

Re:Curl Wttr.in by igor_chubin on Friday June 26, 2020 @09:08AM (#23651543)
Wow! That's cool. Let's try it

  curl() { [ -t 1 ] && curl "$@" | sanitize || curl "$@"; }
Re:Curl Wttr.in by aloknnikhil on Saturday June 27, 2020 @02:43PM (#23663732)
I actually stick to regular formatting on HN because of how terribly code formatting on HN renders on a phone. It doesn't wrap around when you format it as code and I have to scroll horizontally since the width is fixed. But it's probably OK for something like this code snippet.
Re:Curl Wttr.in by igor_chubin on Friday June 26, 2020 @09:09AM (#23651550)
Yes it works! The difference is minimal though (it was intentionally a one-liner)
Re:Curl Wttr.in by progval on Friday June 26, 2020 @03:53AM (#23649735)
> those can include key rebindings; e.g. your Enter key can be rebound to “rm -rf ∗” or “sendfile ∗ [email protected]”.

oh my god. From http://www.termsys.demon.co.uk/vtansi.htm :

> Set Key Definition <ESC>[{key};"{string}"p

> Associates a string of text to a keyboard key. {key} indicates the key by its ASCII value in decimal.

But I can't reproduce it; in my terminal (gnome-terminal), `print('\x1b[97;"echo foo"p')` just shows `cho foo"p`.

So it looks like not all terminals implement it, if any?

Re:Curl Wttr.in by JoshTriplett on Friday June 26, 2020 @04:21AM (#23649863)
No modern terminal implements any of the dangerous escape sequences.
Re:Curl Wttr.in by mdip on Friday June 26, 2020 @12:45PM (#23654051)
As the other poster mentioned, I'm not aware of any terminal that allows these sequences these days.

This wasn't an uncommon thing back in the 90s with DOS ANSI art. I'm not sure if the original ANSI.SYS included with DOS 5/6 but there was a period of time where people remapped things like "echo y|format c:" using ANSI that only required one to "type somefile.ans/txt". The "fix" was to use an accelerated ANSI driver that dropped key-remapping.

Re:Curl Wttr.in by mleonhard on Friday June 26, 2020 @04:05AM (#23649786)
Can you share some information about which terminal applications may be vulnerable to this?
Re:Curl Wttr.in by teddyh on Saturday June 27, 2020 @10:35AM (#23662075)
As other commenters have pointed out, apparently there aren’t any modern ones anymore. My information seems to have been out of date.