News for hackers. Stuff that matters.
Re:I've Just Liberated My Modules by jonahx on Tuesday March 22, 2016 @08:37PM (#11341165)
This seems like a serious security risk. Is there any solution? Would using version numbers without the caret work?
Re:I've Just Liberated My Modules by overgard on Tuesday March 22, 2016 @10:16PM (#11341647)
Not only is there a solution, but it's pretty well known computer science. Use public key cryptography to create a digital signature. It's not even a novel use of this -- .NET has been using this to sign assemblies and packages from day one.
Re:I've Just Liberated My Modules by gbaygon on Tuesday March 22, 2016 @10:49PM (#11341759)
I think he means a solution to the current problem of the packages being replaced with malicious ones, not the problem with npm not supporting package signatures.
Re:I've Just Liberated My Modules by amboar on Wednesday March 23, 2016 @03:40AM (#11342733)
Package signing by the package's author /is/ the solution, right? This way the only entity that can publish a valid update is the the package author. This still has the problem of bootstrapping the trust relationship, and leaves the door open to the author publishing a malicious but signed package or the signing key being stolen and used to do the same. However if you don't trust the package author to be responsible or take precautions against the keys being stolen then you're essentially taking on the burden of implementing of your required functionality.
Re:I've Just Liberated My Modules by lmm on Wednesday March 23, 2016 @05:52AM (#11343121)
We also need some way to link packages to authors. In the Java world packages are supposed to be in a namespace that's the reverse domain name, so you could (potentially, theoretically) connect that up with something like DNSSEC and enforce that people can only publish packages for domains that they control. (Though even that is really just punting the problem up to the DNS registries).
Re:I've Just Liberated My Modules by fapjacks on Wednesday March 23, 2016 @03:33PM (#11347503)
I like your use of "Look, even .NET does this, people".
Re:I've Just Liberated My Modules by throweway on Tuesday March 22, 2016 @09:58PM (#11341564)
Signing using private key?
Re:I've Just Liberated My Modules by ngrilly on Wednesday March 23, 2016 @06:06AM (#11343164)
There is no need to sign. Just keep a cryptographic hash (SHA256 is a good bet) of the package in the dependencies manifest, and check it after download.

Using a git repository gives you that for free.

Re:I've Just Liberated My Modules by alphapapa on Sunday March 27, 2016 @03:41PM (#11371186)
Attacker changes package, then changes hash in manifest to match. Checks pass, users are compromised.

Attacker clones git repo, creates new commit with trojan, pushes to repo with compromised credentials. New users clone compromised repo, others pull and fast-forward. All hashes are valid.

You need to read the Strong Distribution HOWTO: http://www.cryptnet.net/fdp/crypto/strong_distro.html

Re:I've Just Liberated My Modules by ngrilly on Monday March 28, 2016 @01:52PM (#11375933)
I don't get it. If I keep a hash of every dependency in my project, and an attacker change a dependency, I will detect the attack by computing the dependency hash and comparing it with the one stored in my project (for example in the dependencies lock file), which cannot be changed by the attacker.
Re:I've Just Liberated My Modules by alphapapa on Wednesday April 06, 2016 @12:08AM (#11436537)
> ...which cannot be changed by the attacker.

That's fine on your personal system, where you manually update your package's dependencies and manually update the hashes of your package's dependencies.

Now, what happens if an attacker compromises the repo where people download your package from? Or what if he executes a MitM attack on the repo or a user who downloads from it? He can change the entire package, including all manifests, all hashes, etc. Users who download it will be none the wiser. By the time someone notices and corrects it, people will have downloaded the compromised versions and be infected.

The only thing that protects against this is strong crypto signatures. For example, if a Debian mirror were compromised and an attacker uploaded compromised packages, users would be safe, because apt would refuse to install the packages, because they would fail signature verification.

Please read the link I gave. It explains everything in detail.

Re:I've Just Liberated My Modules by grincho on Wednesday March 23, 2016 @11:16AM (#11345223)
SHA1 collisions are affordable for large actors now and getting cheaper all the time, so git, with its SHA1 assumptions hard-coded, unfortunately doesn't protect you anymore. But the local hash approach is a good one, proven in pip 8 (Python) and npm-lockdown (JS).
Re:I've Just Liberated My Modules by throweway on Thursday March 24, 2016 @05:52PM (#11356768)
More for new versions of same software where the account might be highjacked but hopefully the key wasnt. I dont think a hash would help.