News for hackers. Stuff that matters.
Re:Detecting the use of “curl – bash” server side (2016) by thombles on Wednesday December 09, 2020 @05:00AM (#25357010)
Those advocating we inspect the downloaded script surely wouldn't rely on plain old "cat" would they? :) https://www.infosecmatter.com/terminal-escape-injection/
Re:Detecting the use of “curl – bash” server side (2016) by VBprogrammer on Wednesday December 09, 2020 @05:25AM (#25357178)
Pfft, that would be a Useless Use of Cat[1].

[1]http://porkmail.org/era/unix/award.html#cat

Re:Detecting the use of “curl – bash” server side (2016) by dspillett on Wednesday December 09, 2020 @06:31AM (#25357555)
Many examples of "useless uses of cat" are useful IMO because they improve clarity.

  cat some.file | a_process | another_process > output.file
is clearer than

  a_process < some.file | another process > output.file
IMO because it maintains a simple left-to-right flow. I can mentally translate between the two without thinking about it, as no doubt can you, but the clarity could be useful to others (including tired me after a long day!).

Yes it wastes a bit of processing time and memory, but if what you are doing is going to significantly benefit from that small saving is the shell the right place to be doing it anyway?

Re:Detecting the use of “curl – bash” server side (2016) by VBprogrammer on Wednesday December 09, 2020 @07:16AM (#25357778)
This argument has been done to death. For the record yes, I agree with all of that and secretly I use it all the time.

I only invoked the "useless use of cat" demon because in this case it makes an interesting difference. Less doesn't evaluate the escape sequences which make this attack work by default.

Re:Detecting the use of “curl – bash” server side (2016) by Ambroisie on Wednesday December 09, 2020 @07:01AM (#25357716)
You can put the redirection before the command name, which keeps the same left to right flow.
Re:Detecting the use of “curl – bash” server side (2016) by dspillett on Wednesday December 09, 2020 @07:37AM (#25357877)
Though the arrow still points the wrong way, if I'm being fussy.

I was also about to suggest that was shell specific so not available everywhere, but a quick test says it is supported by /bin/sh at least so might be POSIX and therefore widely available.

Re:Detecting the use of “curl – bash” server side (2016) by ImaCake on Wednesday December 09, 2020 @05:42AM (#25357273)
Does it matter if it's bad form if every terminal noob does it anyway? An attacker using this vector certainly wouldn't care - so long as the attack works.

There's definitely a place for poking fun at Unix noobs - I have learnt better tools than cat because of it - but it is not terribly relevant here.

Re:Detecting the use of “curl – bash” server side (2016) by oblio on Wednesday December 09, 2020 @07:43AM (#25357912)
It's not even a noob thing. I've been using using *NIX for 15+ years and I still don't subscribe to this "useless use of cat" pedantry.

Without cat I need to use redirections or find the parameter for each command I use, in order to get things from a file.

cat bla | command1 | command2

is much nicer to write and read, much more logical and much easier to modify if needed.

"Useless use of cat" is a micro-optimization. Use if you want or need, don't turn it into dogma or even better, newbie shaming (yay for gatekeepers!).

Re:Detecting the use of “curl – bash” server side (2016) by VBprogrammer on Wednesday December 09, 2020 @05:47AM (#25357306)
It's actually one of the few cases where there is a functional difference between using cat and the alternative. Using less instead wouldn't execute the escape sequences.
Re:Detecting the use of “curl – bash” server side (2016) by turminal on Wednesday December 09, 2020 @07:37AM (#25357879)
Unless the user has less aliased to `less - r` which many users do.

I wouldn't be surprised if there existed some obscure distro that ships this alias in the default bashrc