Live data from Hacker News

Don't copy paste from a website to a terminal

thejh.net

11–20 of 257 posts

Re: Don't copy paste from a website to a terminal

#11

I don't get it... even if the pasted content has stuff I don't expect, I still see it in my shell prompt before I press Enter, no?

No, unfortunately not.

I did a "cat >/dev/null" before pasting so I could see what it was. Clever masked/hidden content, with embedded shell commands and newline to commit the commands.

Re: Don't copy paste from a website to a terminal

#13
post #4

A good terminal should show you the full pasted text in a confirmation popup before executing it. Also should never accept new lines from a paste. Or rather; if and when the paste contains new lines, it should show a confirmation popup so you know what the hell you're executing.

Elementary OS shows a warning message when a sudo command is copy pasted in to the terminal.

Re: Don't copy paste from a website to a terminal

#14
> Hello scdf!

> That was a bad idea. Don't copy code from websites you don't trust!

Or indeed, download software from websites you don't trust.

I guess the worry would be that hackers would, as an example, take over brew.sh and do bad stuff with installation url. As opposed to taking over brew.sh (in an alternate world where brew.sh hosts a dmg file or something) and hosting an entirely different file.

Bar the relative ease of hiding bad stuff in copy paste compared to making a fake dmg file, this seems to be basically the same situation no?

Re: Don't copy paste from a website to a terminal

#16
post #4

A good terminal should show you the full pasted text in a confirmation popup before executing it. Also should never accept new lines from a paste. Or rather; if and when the paste contains new lines, it should show a confirmation popup so you know what the hell you're executing.

iTerm2-Nightly (not sure about main) notifies you on multiple line paste, but does not provide the contents.

Re: Don't copy paste from a website to a terminal

#17
post #7

I don't get it... even if the pasted content has stuff I don't expect, I still see it in my shell prompt before I press Enter, no?

If there's a newline in the pasted contend it's already too late.

Ah, thanks for pointing that out.

Re: Don't copy paste from a website to a terminal

#18
Should I consider my browser betraying me by selecting stuff that's outside the viewport without a hint / warning ? (absolute positioned element, (-100,-100)). It's simply too convenient to copy/paste from the browser.

P.S. I have a paranoid habit of pasting copied text into the address bar or a notepad to quickly check for unwanted characters. For once, I don't feel like I'm crazy.

Re: Don't copy paste from a website to a terminal

#20
Aside: its not sufficient to look at a file you 'curl | bash' into bash via your browser. It is very trivial to detect curl/wget's UA (mine has: "User-Agent": "curl/7.43.0") and dynamically modify files depending on the request's UI.

    if 'curl' in request.UA:
         return 'something malicious' 
    else:
         return 'something nice'
Always create a local file with the content, read it, then perhaps run it.
Post reply on HN