Don't copy-paste terminal commands from the web

[Read the post]

3 Likes

As an addendum, never install anything in a command line by piping the results of a curl command directly to the shell. This is disturbingly common. For example the standard Ruby Version Manager suggests you install it like this:

\curl -sSL https://get.rvm.io | bash

Don’t do that, and if anyone asks you to do that, they should feel bad.

13 Likes

ha ha ha ha! Suckers!

3 Likes

I LOLed!

I am a Linux novice, but am aware of the possibility of easily hosing or unsecuring my system.

If I had to copy something off the web, I would paste it into a text buffer instead, to be sure of what it was. Pasted stuff could include even a return/enter character to run it automatically from a terminal.

Better yet, use the “man” command with your binary of choice as an argument, so you can learn what they are, what they do, and what arguments they accept. Then you are in a better position to know a bit about how your system works.

8 Likes

[quote=“FTFA”]
Mark it with your mouse, copy it somehow (e.g. using CTRL+C) and paste it into a terminal. What happens?
[/quote]Since I’m not on a Linux machine, I have no idea. It would be nice if TFA told us what it did without making us actually do it under the specific OS you’re not supposed to do that sort of thing on…

3 Likes

If someone gives you a bad shell command, just do what I do and delete /etc. Works every time.

(In case it’s not obvious: Do NOT delete /etc unless you know what you’re doing and why.)

Also, for that matter, do not pour salt water into your computer or place your laptop in the microwave. Even if someone from technical support tells you to. Perhaps especially if so.

5 Likes

I just gave the links a quick glance, but the main attack vector seems to be text stings with partial obfuscation via CSS display props. (Here’s one source)

Works fine against Windows, too. The linked Reddit thread covers some of that, but it’s a long wearisome thread…

I’m a fan of keeping a 7-bit editor handy to wash copy operations from web pages.

2 Likes

I paste into notepad as a habit cause windows likes to be ‘smart’ on me and do fancy crap I don’t want done with formatting which I never ever want.

12 Likes

buuut laaazyness! Also, if you’re copying code from a site that you’re pretty much running compiled software as root, you’re really only opening yourself up to some nasty XSS, but it is a good reminder to not just trust some stranger’s code. Recalling a script I wrote with a bunch of “rm -rf” commands, you could get some interesting glitches by adding “-exec sed -i “s#/bin#\ /bin#g” {} ;” to an overly inclusive find command.

I think it’s mostly Word. I’ve taken to writing in Notepad++ when I need to make something to paste into a webform.

1 Like

Can we have the old web back?

With just text files, images, and links to other text files and images?

I thought this topic would just be a reminder not to run commands you don’t understand.

But actually the article warns us about something that should not even be possible.

4 Likes

Uh, the tl;dr is wrong; this has nothing to do with JavaScript.

9 Likes

I was thinking of writing an endorsement of an Oh-My-Zsh plugin, safe-paste.

Then I remembered that the way the Oh-My-Zsh people recommend installing Oh-My-Zsh is with wget or curl, piped through sh.

And that’s not much different from how Oh-My-Zsh updates itself.

Suddenly, I don’t feel like Oh-My-Zsh is so clever.

2 Likes

Seconded - the TL;DR should talk about shell commands, not Javascript. This particular exploit doesn’t involve Javascript.

And nothing is being automatically executed here; the end user is explicitly pasting commands into a terminal in this scenario.

3 Likes

This exploit doesn’t work if you aren’t allowing scripts by default. Which I’m not. So, problem solved in 0 easy steps.

2 Likes

There is a similar problem with web links. Some sites will have a link that you think is directly taking you to the target site, but it is actually wrapped in a tracking web site like viglink full of information about who you are and where you came from.

1 Like

As if they could possibly understand! XD

2 Likes

I was suspicious of this too. I wasn’t under the impression that clipboard contents were executed or interpreted.

3 Likes

wait what? this is a joke right?

if serious, on what os? which javascript engine is running it from the clipboard? the linked to clever fellow explanation says no such thing…I program javascript all day and cut and paste javascript like a champ, nothing ever runs. I’ll assume this is just a joke and I’m not getting the humor.

nothing should ever run from the clipboard directly…unless you have the worlds worst clipboard extension installed.

3 Likes

This LINK talks about clipboard poisoning…which still doesn’t execute automatically from the clipboard, rather it changes the clipboard content from what you think you copied to something less desirable. You still have to paste it into a terminal to execute.

3 Likes