News for hackers. Stuff that matters.
Re:PHP: The Right Way by aw3c2 on Saturday July 07, 2012 @06:24PM (#4212920)
curl -s http://getcomposer.org/installer | php

is creepy. Never ever run other people's code without at least giving it a glance.

Re:PHP: The Right Way by wvenable on Saturday July 07, 2012 @06:33PM (#4212935)
Reminds me of how you get mysqltuner:

wget mysqltuner.pl

perl mysqltuner.pl

(Yes, they actually have a .pl domain for it)

Re:PHP: The Right Way by zdw on Saturday July 07, 2012 @06:32PM (#4212933)
RVM's installation is similar:

https://rvm.io/rvm/install/

A far cry from the safer/verified "download this and check it's MD5 checksum" method that I'd prefer.

Seriously, fixing package management so we can continuously integrate arbitrary code would be great. Getting arbitrary OS package creation to be almost as easy as pushing code to GitHub seems like a very worthy goal.

Re:PHP: The Right Way by anthonyb on Saturday July 07, 2012 @09:08PM (#4213221)
md5 is not going to protect you from much, especially if the md5 checksums are hosted on the same server.

Also, pushing random code via apt-get is not going to win you any sysadmin friends. They like their servers to be stable, and their packages to be well tested.

Re:PHP: The Right Way by zdw on Sunday July 08, 2012 @12:22AM (#4213611)
Seeing as you can remove said code via apt, you'd likely win them over compared to the alternative of being told to install compilers or some other non package managed software bundler like cpan/rvm/npm that can't be canned and easily deployed.
Re:PHP: The Right Way by anthonyb on Sunday July 08, 2012 @01:57AM (#4213811)
But why would you remove it? Because whatever you've installed has broken.

Much better not to be broken in the first place.

Re:PHP: The Right Way by adient on Monday July 09, 2012 @07:27AM (#4217611)
It seems you live in an idyllic world far, far away from reality.
Re:PHP: The Right Way by brohee on Monday July 09, 2012 @10:06AM (#4218205)
It's not the nineties anymore, MD5 doesn't protect you from much, and especially not from the author of the original package creating an alternate version.

Viable verification is based on an unbroken hash (preferably SHA-(256|384|512), but SHA1 still not broken even it it's definitely too short nowadays. And the hashes need to be distributed properly, either PGP signed or hosted on a trusted TLS protected site...

Yet many projects still distribute MD5 hashes, thinking it got any value.

Re:PHP: The Right Way by mark_story on Sunday July 08, 2012 @01:09AM (#4213712)
For the longest time the installation instructions for NPM were almost exactly the same. But its worse when PHP does it :)
Re:PHP: The Right Way by denysonique on Sunday July 08, 2012 @07:54AM (#4214388)
In terms of security this is no different than executing someones binary or building a big code base.
Re:PHP: The Right Way by 1amzave on Saturday July 07, 2012 @06:47PM (#4212959)
Indeed, especially coming after this further up the page:

> Never ever (ever) trust foreign input introduced to your PHP code.

Where'd I put that sense of irony...

Re:PHP: The Right Way by ecaron on Saturday July 07, 2012 @07:09PM (#4213002)
Except that there's a significant difference between "trust" of input from the user vs. "trust" of the software stack you use as a foundation.

Unless you've read every line of the Linux kernel, we all succumb to the later point sooner or later.

Re:PHP: The Right Way by wilmoore on Monday July 09, 2012 @04:15PM (#4220162)
If you don't like that command, do this instead:

    > curl -s http://getcomposer.org/composer.phar -o $HOME/local/bin/composer ; chmod +x $HOME/local/bin/composer
Assuming that $HOME/local/bin is in your $PATH, the current user will have a "composer" command available.
Re:PHP: The Right Way by mcantor on Sunday July 08, 2012 @12:46AM (#4213674)
Yeah... only idiots "sudo aptitude install" without reading and building from source first!
Re:PHP: The Right Way by dsl on Sunday July 08, 2012 @01:28AM (#4213752)
You really can't tell the difference between blindly executing input from an insecure HTTP connection, and installing packages with a tool that verifies cryptographic signatures against known good keys shipped with your distro?

Mr. Cantor, I have added to the list of people to never hire I keep in my notebook.

Re:PHP: The Right Way by walrus on Sunday July 08, 2012 @06:35AM (#4214272)
You can explain the difference without attacking the person you're replying to.
Re:PHP: The Right Way by huhtenberg on Sunday July 08, 2012 @02:32AM (#4213879)
The risk of picking up malicious executable from the legit server is far higher than that of picking up a malicious executable from an impersonating server. Practically speaking.
Re:PHP: The Right Way by mcantor on Sunday July 08, 2012 @04:12AM (#4214067)
So? Who says the verified package isn't malicious? My point isn't about cryptography, it's about complexity. Unless you personally read through every line of code, how do you really know that there isn't something in there waiting to screw you over?
Re:PHP: The Right Way by aw3c2 on Sunday July 08, 2012 @04:33AM (#4214096)
I trust my system's package maintainers and the signing makes sure that it is them.

I do not trust a random website that could easily be MITMd.

Re:PHP: The Right Way by VMG on Sunday July 08, 2012 @06:48AM (#4214295)
So you'd be fine with https?
Re:PHP: The Right Way by brohee on Monday July 09, 2012 @10:10AM (#4218229)
You don't know. What you know however is who to sue if the package ends up being malicious, thanks to the signature.
Re:PHP: The Right Way by batista on Sunday July 08, 2012 @04:13AM (#4214068)
And I've added you to the list of guys that think they are "the shit" because they have hiring abillities (in some shitty company) and need to tell it on the intertubes.
Re:PHP: The Right Way by codeguy on Saturday July 07, 2012 @06:25PM (#4212922)
haha. Always good advice. But I checked. It's fine :)
Re:PHP: The Right Way by chrismsnz on Saturday July 07, 2012 @09:07PM (#4213216)
It's fine now until someone hacks their site or poisons their DNS.
Re:PHP: The Right Way by anthonyb on Saturday July 07, 2012 @09:32PM (#4213262)
Or writes a script which checks the user agent and only serves up malware to curl.

Or the second time that an IP address hits it.

Or something else that you haven't thought of.

Update: Such as doing something nasty to http://getcomposer.org/composer.phar instead - a 520KB php file that the first script downloads and runs without even md5ing first. Did you audit that too? Did you understand everything that it was doing?

Re:PHP: The Right Way by larrys on Saturday July 07, 2012 @11:09PM (#4213448)
Or social engineers their registrar and changes their dns.
Re:PHP: The Right Way by timaelliott on Saturday July 07, 2012 @06:48PM (#4212962)
That's really just a question of trust. If you know what Composer is, you trust it.

'apt-get install whatever' is just as magically scary and dangerous.

Re:PHP: The Right Way by Kudos on Saturday July 07, 2012 @07:03PM (#4212986)
No it isn't, there's GPG signing and things going on there.
Re:PHP: The Right Way by Udo on Saturday July 07, 2012 @07:12PM (#4213007)

  No it isn't, there's GPG signing and things going on there.
That's really just Cargo Cult security, isn't it? Signed packages can just as easily be malicious. In fact a repository server could be a much worthier target for the injection of bad code than a single, relatively obscure web project.
Re:PHP: The Right Way by anthonyb on Saturday July 07, 2012 @09:03PM (#4213210)
The repository doesn't have any access to the developer's private key. That's exactly the attack that they're designed to mitigate.
Re:PHP: The Right Way by Dylan16807 on Saturday July 07, 2012 @07:24PM (#4213029)
The difference is the same as between http and https.
Re:PHP: The Right Way by Udo on Saturday July 07, 2012 @07:30PM (#4213036)
Exactly. SSL doesn't guarantee that the content is benign either. But there is also a key difference when it comes to software distribution. On a typical web connection you worry about 3rd parties observing your content and maybe even spoofing it later (e.g. stealing your cookies), but as far as downloads are concerned your main worry is actually content integrity. This integrity is threatened by both malicious publishers and outside attackers injecting malicious code into otherwise benign software - having a GPG signature alongside your rpm does (almost) nothing to mitigate that risk.
Re:PHP: The Right Way by jasonlotito on Saturday July 07, 2012 @07:39PM (#4213050)
Not sure if you are trying to make a joke (and if so, it's incredibly subtle), or you are being serious. In case you are serious, to explain how HTTPS as it's used means anything about the trust-worthiness of the two parties involved?
Re:PHP: The Right Way by Dylan16807 on Saturday July 07, 2012 @08:22PM (#4213132)
Look at the original post. "curl -s http://getcomposer.org/installer | php" It's not just about trusting Composer, it's about trusting every point between you and their server. If I want to know that I am actually executing Composer I need to use a secure download method.
Re:PHP: The Right Way by eli on Saturday July 07, 2012 @09:09PM (#4213222)
I don't disagree with you, but if you've got someone actively trying to exploit you sitting between you and the Internet, you've got bigger problems.
Re:PHP: The Right Way by simonbrown on Saturday July 07, 2012 @10:29PM (#4213377)
Someone trying to find an exploit is a bigger problem than giving them one?
Re:PHP: The Right Way by eli on Saturday July 07, 2012 @11:35PM (#4213508)
Oh, definitely. If someone has a launched a targeted attack against you and they already have the ability to seamlessly view and modify your internet traffic, you are in pretty serious trouble whether you download your development tools from wget or apt-get.
Re:PHP: The Right Way by anthonyb on Saturday July 07, 2012 @11:55PM (#4213556)
Except that apt-get will check GPG signatures and detect that kind of attack. How is a MITM attack going to find a 3rd party's private key?
Re:PHP: The Right Way by jasonlotito on Saturday July 07, 2012 @11:49PM (#4213541)
I'm looking at the post you replied to. So maybe you replied to the wrong post, or ignore context and tried to be witty or smart.

In context, what you say makes no sense.

Regardless, https would be better, but if you are that nervous as you suggest you are, then https doesn't solve your problem either. Neither does some hash thrown up on some site for you to compare against.

Re:PHP: The Right Way by Dylan16807 on Sunday July 08, 2012 @02:07AM (#4213830)
Here, how about I summarize my view of the conversation for you.

  aw3c2: 'curl | php' is creepy
  timaelliott: apt-get is just as scary
  kudos: no, it has signing
  udo: that's cargo cult
  me: no, it protects like https (meaning it authenticates and stops MitM)
I was responding perfectly in context to point out how the protections apt-get have are useful. I also tied it back into the original comment but you can ignore that part if you like. I don't know why you think I was 'trying to be witty' and ignoring context.
Re:PHP: The Right Way by jasonlotito on Sunday July 08, 2012 @08:29AM (#4214426)
Ahh, gotcha, that better explains it.

Still, https doesn't validate anything. You could add a certificate, but then that only means you are talking to the server assigned the cert, not that the actual package is good.

I still stand by what I said: mountain and mole hills.

Re:PHP: The Right Way by anthonyb on Saturday July 07, 2012 @09:20PM (#4213242)
It does not help you if the originating server has been hacked, which is by far the most likely attack vector (after people being assholes on the internet or making mistakes in their script).

Protecting against that is the whole fucking point of using things like apt-get/PEAR and GPG/code signing.

Re:PHP: The Right Way by brohee on Monday July 09, 2012 @10:08AM (#4218217)
Signed packages can be just as malicious, but the security of the mechanism relies on the signer not wanting to do jail time, thus protecting his secrets and not signing stuff he doesn't trust.