News for hackers. Stuff that matters.
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by toxik on Thursday September 01, 2016 @05:35AM (#12403953)
And to run it from the clipboard:

    pbpaste | sh -
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by IanCal on Thursday September 01, 2016 @06:13AM (#12404096)
If anyone wonders why this is taking too long, you may have done the same daft thing I just did, which was to copy the first command and then copy pbpaste | sh -. The latter will of course create an infinite loop.
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by raldi on Thursday September 01, 2016 @06:24AM (#12404151)
Why would copying two strings to the clipboard lead to an infinite loop?
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by stable-point on Thursday September 01, 2016 @06:32AM (#12404184)
If you have `pbpaste | sh -` on your clipboard and then paste it into a terminal, it'll continually execute itself.

(`pbpaste | sh - | pbpaste | sh - | pbpaste | sh - | ... | pbpaste | sh -`)

Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by IanCal on Thursday September 01, 2016 @07:11AM (#12404335)
It won't, but running

    pbpaste | sh -
Means it's taking whatever is in my clipboard and executing it.

I had replaced what I wanted to execute with just "pbpaste | sh -"

So it passed "pbpaste | sh -" to the sh to run. Which would have then taken "pbpaste | sh -" and passed it to sh to run, which ...

Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by Hates_ on Thursday September 01, 2016 @06:33AM (#12404190)
I believe it would the same as this I think?

  pbpaste | sh - | sh - ...
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by clishem on Thursday September 01, 2016 @08:13AM (#12404630)
Or just copy and paste the above?
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by labster on Thursday September 01, 2016 @05:50AM (#12403999)
Why not this?

    curl https://gist.githubusercontent.com/kaizensoze/ca96d039b295db220951d42ca7c83d89/raw/ | bash
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by okket on Thursday September 01, 2016 @05:55AM (#12404015)
Your line downloads and executes the latest version of the gist, it could have changed from a file check to a virus installer by the author (unlikely, but I have to point it out). To be a bit more safe (while trusting that GitHub is not compromised) pin a known, verified version:

  curl https://gist.githubusercontent.com/kaizensoze/ca96d039b295db220951d42ca7c83d89/raw/a26e5a025ea21d3a0af536eeca49619272d0068f/quick-osx-keydnap-check | bash
(sorry for the overlong line)
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by heeen2 on Thursday September 01, 2016 @08:43AM (#12404798)
this pattern is just as dangerous (maybe less for github if you trust them) because you can detect curl and deliver malicious code: https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-b...
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by okket on Thursday September 01, 2016 @09:13AM (#12404953)
> this pattern is just as dangerous

As a general pattern, please do not do this. In this specific case I think most people trust the service (GitHub) and their DNS recursor + SSL library. Attacking these is not on the level of "random drive-by phishing", more like "targeted high value state sponsored".

To avoid this discussion I did not include the curl version in my original posting.

Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by theandrewbailey on Thursday September 01, 2016 @08:12AM (#12404621)
Yeah, let's download and blindly run stuff directly from the internet (that may have changed since we last saw it) without saving and trying to read what it does first.

If you can copy/paste the curl | bash, is it really more difficult to copy/paste the original snippet into a text editor[0], and from there, into bash?

[0] https://thejh.net/misc/website-terminal-copy-paste

Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by andrepd on Thursday September 01, 2016 @08:54AM (#12404850)
So you would run code by pasting it from the internet just fine, but doing so via a pastebin is a security risk?
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by JadeNB on Thursday September 01, 2016 @11:02AM (#12405740)
If you C&P it, at least you see what's being C&P'd (although it's up to you to take the trouble to understand it). `| bash`ing it runs it automatically, without even giving you a chance to see it.

EDIT: This comment was based on the assumption that my parent hadn't read carefully. My facile point ignores both the specific vulnerability pointed out by [czinck](https://news.ycombinator.com/item?id=12406080) below, and the general vulnerability that you just can't trust anything pulled in from an external source. I think that re-directing to a file, and viewing the file with something like `:set list` set in `vim`, will work, at least in the sense of showing you the code that will actually be executed (although nothing can save you from not understanding the code), as long as you can trust your own stack. However, it is a near-certainty that this edit will prompt someone to explain how to exploit that. (That may sound like whingeing, but it's just a (happy) acknowledgement of the hacker mentality; unexpected exploitations, as PsoC rather than attacks, are pretty neat, too!)

Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by czinck on Thursday September 01, 2016 @11:33AM (#12406080)
C&P is not really more secure than curl as with some javascript you can easily mislead users as to what they're copying. Check https://thejh.net/misc/website-terminal-copy-paste and similar PoCs.
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by ultramancool on Thursday September 01, 2016 @11:43AM (#12406192)
Yeah, I keep stuff like that disabled for this reason, and because random sites like to add urls when you copy text.

Just set dom.event.clipboardevents.enabled = false.

Some shells also handle the paste and try to detect anything funny going on or at least let you review before you execute.

Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by JadeNB on Thursday September 01, 2016 @01:52PM (#12407416)
> Just set dom.event.clipboardevents.enabled = false.

Your parent's link's trickery is to do not with JavaScript (it just uses raw HTML), so this would not mitigate that attack:

    <p class="codeblock">
      <!-- Oh noes, you found it! -->
      git clone
      <span style="position: absolute; left: -100px; top: -100px">/dev/null; clear; echo -n "Hello ";whoami|tr -d '\n';echo -e '!\nThat was a bad idea. Don'"'"'t copy code from websites you don'"'"'t trust!<br>Here'"'"'s the first line of your /etc/passwd: ';head -n1 /etc/passwd<br>git clone </span>
      git://git.kernel.org/pub/scm/utils/kup/kup.git
    </p>
> Some shells also handle the paste and try to detect anything funny going on or at least let you review before you execute.

The link also mentions that bracketed paste mode does not prevent this attack:

> Please note that _Bracketed Paste Mode DOES NOT always fix this_ because the end sequence can be inside the text you paste unless your terminal emulator filters out the bracketed paste characters when pasting!

Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by ultramancool on Friday September 02, 2016 @01:08AM (#12410975)
You missed a key point:

> unless your terminal emulator filters out the bracketed paste characters when pasting!

Any sane terminal should already be doing that, if not there's not really any point in offering bracketed paste in the first place as any input could break out of it.

Of course, this should really be on the browser for not delivering the proper text that the user selected to the clipboard.

Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by JadeNB on Saturday September 03, 2016 @09:53AM (#12419188)
> Any sane terminal should already be doing that, if not there's not really any point in offering bracketed paste in the first place as any input could break out of it.

I wanted to test whether the Mac OS Terminal.app does that, but can't even figure out how to turn on bracketed paste mode in the first place. (All a Google search turns up is an SO result assuring me that Terminal.app supports BPM. I can't find it anywhere in the settings.)

> Of course, this should really be on the browser for not delivering the proper text that the user selected to the clipboard.

On the other hand, it's hard to give an argument for how the browser should know that the user didn't mean to select the extra portion of the text. I know that I am always resistant to solutions where my software insists that it knows better than I do. Maybe a prompt if the selection includes invisible text? (I guess the browser can tell whether some of the text being selected is out of the view window.)

Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by ahoka on Thursday September 01, 2016 @06:13AM (#12404090)
It would be kind of ironic to do this.
Re:Transmission BitTorrent Client OSX/Keydnap Malware Incide... by varcharlie on Thursday September 01, 2016 @01:54PM (#12407437)
Let us execute random things from the internet directly on our machines without first checking their sanity.