Hacker News new | ask | show | jobs
by seldo 2660 days ago
This really isn't news, folks. It happens every week. I was just grumpy this morning.
6 comments

If this happens often, perhaps the user interface for npm publish needs to change? I mean, that's the only thing I can see mitigating this, with like a nice dialog that says "hey, are you REALLY REALLY sure and have you consulted lawyers on this???"

Or something to that effect. Or maybe companies can just pony up for NPM Enterprise which fits their use case.

I work at a major bank and for the US Army. Both of those organizations are hyper sensitive about security for good reasons. Unfortunately that hyper sensitivity often results in really bad decisions and gross misunderstanding of software.

Publishing software is not a security violation in greater than 98% of cases. The only valid exceptions are protections of trade secrets and cryptographic information.

I am not counting software with embedded credentials, embedded business data, or other bad practices. Those are security violations regardless of public exposure.

Trying to explain this to security sensitive organizations is painful. I am confident in the stupidity of this conversation as somebody who has been writing code for more than 20 years and passed the CISSP exam the first time back when it was a 250 question paper test.

I'm trying to understand your point. I agree with the basic premise that most pieces of code that end up not getting exposed are not sensitive, but building guardrails to ensure people who aren't security minded ask the right questions and get closer to 'default correct' ends up being a requirement in major banks/government organizations. The number of times someone has done something completely silly like include API keys in a public package or Git repo is reason enough to care. Being beholden on an external system being secure and up to standard ruins pretty much every category of a risk analysis, especially when you end up with gold like this article or the PHP PEAR hack.

Then there is always that part of the organization that isn't judicious about keeping packages up to date, and these kinds of package exposures expose their negligence.

Then there is the other piece of my systems being dependent on your systems in a sometimes inappropriate matter if precautions aren't taken. 'Oh I just added this dependency' is a quick way to an outage if rules aren't set.

> The number of times someone has done something completely silly like include API keys in a public package or Git repo is reason enough to care.

Agreed, but that is not a publication problem. That is a separation of concerns violation which indicates a host of other problems from the lack of code review to incomplete security testing to various ad hoc or integrity violations.

External systems have no bearing on the validity and completeness of your organizations internal security controls. It doesn't matter how incomplete, insecure, or unqualified NPM is to serve a given set of code. The problem isn't NPM or the publication to NPM. The problem is the contents that comprise the publication in question. A good security audit would ask why any certain content is available for publication in violation of internal policy regardless of what that content is.

For example if you accidentally publish to NPM code containing a bunch of user PII the problem is why PII was resident in the code in the first prior to publication. The fact that such PII is exposed is now a different second problem demanding a different resolution. You could make the argument that halting and regulating all publications would solve that problem. That is incorrect, because the PII is still exposed within your organization outside of a controlled environment and can still be leaked to the public by various other means.

> Then there is always that part of the organization that isn't judicious about keeping packages up to date, and these kinds of package exposures expose their negligence.

That is dependency management whether or not you own the packages in question. Dependencies need to be appropriately managed for a variety of security reasons. Exposing poor dependency management advertises a vulnerability, but the vulnerability is there anyways and a dedicated malicious attacker will exploit it the same either way.

---

The bottom line is that hiding your security problems by "not publishing" is not a valid security control. That is the dreaded security by obfuscation and it works both ways. By hiding the vulnerability you also hide the exploitation from visibility.

You could not have a default. Then in order for someone to publish to the public NPM, they'd have to enter the URL for the public NPM. Otherwise publish should fail.
No alert box ever will save you from doing the biggest mistakes, most people don’t read them.
Just compare this to publication to Maven Central - you’ll never publish there by accident exactly because there are significant barriers. Public NPM repo should not be that easily accessible for upload.
At some points in a language and its package management system's lifetime, reducing barriers to publishing are one of the best things that can be done to increase packages and fill out the ecosystem, and drive utility and adoption.

Later, once you have most needs filled by packages, and a good number of enterprise users, more control is beneficial. Companies appreciate it, and single users are willing to jump through an extra hoop or two much of the time because the rest of the ecosystem is so useful that it's not worth switching languages.

I think it's unlikely that a system will move from one style to another without an event causing them to reevaluate their prior choices. More likely, multiple events. This has already happened with NPM for other choices they made in the past, such as letting package namespaces be claimed by new people after someone gives it up, and whether releases are immutable, IIRC.

Please don't think this way.

This is such a solvable problem.

Doesn't package.json have an is private repo flag? Why not just respect that?

Why does everyone everyone in this thread think a pop up is the solution?

Pop ups are a code smell. They mean your application does not correctly match user intent with the action so badly you had to specifically get your user to tell you what they meant to do. Did you mean to do that? Always, yes. Otherwise, undo.

The only place did you mean makes sense is in Google search results.

Why is public and private publish anywhere near each other? Why are they even on the same page?

Stop drawing boundaries around nouns.

> Doesn't package.json have an is private repo flag? Why not just respect that?

npm does reflect that flag. If you set private in package.json, npm won't publish it publicly. From docs:

> private

> If you set "private": true in your package.json, then npm will refuse to publish it.

> This is a way to prevent accidental publication of private repositories. If you would like to ensure that a given package is only ever published to a specific registry (for example, an internal registry), then use the publishConfig dictionary described below to override the registry config param at publish-time.

> Pop ups are a code smell. They mean your application does not correctly match user intent with the action so badly you had to specifically get your user to tell you what they meant to do.

Not a rule. Do you really want undoable actions like "Delete" to just delete in a touch operated interface?

I disagree, there have been times a well-placed popup stopped me from accidentally doing something really stupid, other times there wasn't a popup and I ended up doing something stupid.

It doesn't necessarily have to be a pop up popup per say, but extra validation around dangerous actions is user friendly.

And of course there can always be an override for the extra validation in case it potentially screws up some people's workflows, but I'd make a user explicitly set the override, like the 'NoHostAuthenticationForLocalhost' option in ssh for example.

I wasn't condoning popups. I was making a high level observation of package systems in general.

That said, I fully support a terminal level confirmation the first time something is pushed publicly in any package manager. It is absolutely the correct thing to do to add safeties to a process that is irreversible and can have negative consequences. Often enough, making anything public online is irreversible, and making something public that wasn't ever supposed to be can have negative consequences in many respects.

But what I was really thinking of when I was typing my original comment was moving to a system where someone actually approves new package publishing accounts and or some subset of package namespace requests. Systems that start without any sort of moderating or approval process seem to eventually settle on one. The reasons for this are numerous, from security to just keeping people from overwhelming the more common or sought after names and general sanity checks (does a system really need to allow separate packages for a term where one is singular and one is plural? Who does that help?).

npm publish already prevents you from publishing a package that has the private flag. They must not have had it set.
This is going to be cynical, but as far as I understand it people are looking for usability through vanity.

Why not install `com.facebook.react’? Reverse domain notation is remarkably elegant given our internet. You are not typing ‘npm i com.facebook.react’ so often that it’s a pain. You probably use ‘create-react-app’ which is even worse.

Instead, every language creates a new cash grab for common names. And made it worse. New namespaces, new squatting. I can publish ‘react-racket’ and do whatever I want behind the scenes with it.

Case in point: do you add coffeescript or coffee-script.

Why optimise for keystrokes in your term instead of stability for your client? Jesus fuck.

The JavaScript community is moving into the Enterprise and is discovering Java's good ideas from 1995
> Why not install `com.facebook.react’?

That would be a bad idea, and it's not just brevity.

- If com.facebook.hr has previously been published, would it mean that facebook can never have a division named HR?

- Once a company goes belly up, the domain often ends up with squatters/spammers. Domains with published packages will sell for a lot more in the underground market - for pure exploitation of rights to publish a newer version.

- In the absence of validation, nothing stops anyone from publishing com.google.exploitlib. And domain validation is friction.

- Most publishers on npm may not have a domain.

And finally like someone mentioned below, npm already supports scoped packages. https://docs.npmjs.com/about-scopes

There's a little bit of movement happening in that direction in the npm world with scoped packages. E.g. babel moving all official packages to @babel. Storybook does it too. Doesn't even have to be much of a branding loss. FB could publish @react/react, @react/native, @react/eslint-config, @react/create-app, @react/prop-types, @react/dom... Most of the typing is happening in require/import not npm install, so there's some argument for not going the full java route.
Setting `private: true` to your package.json will prevent this from happening
setting `public:true` would solve this problem
But default should be public - it's an open source piece of software
What you're describing is consumer protection, but a company isn't a consumer. The bank responsible for their own actions.
No, the first step is to say you haven’t set a publish source. Your toolkit might generate that but you should also see that in code review.
It should not auto create accounts. Compared to Nuget. I find NPM absolutely scary to use because it’s unpredictable. (Personal opinion)
It would be good if there were a standard format for referencing private keys in code, like "pk_*". Then NPM could say,

> "it looks like your package might have a private key in file xyz.js on line 27. Please type "no it doesn't" into the box below if you're sure this is not the case".

Adding 'private: true' to the package.json prevents publishing to _any_ registry, including a corporate proxy. Adding a string or regex option for private that would only publish to matching registries may prevent issues like this.

I ask for regex only because our corp proxy binds to a random port reach time it runs so a static string wouldn't be flexible enough.

Why isn’t this a source URL?

Took a while for Ruby to get it but for the last 5 years you have default config for self-hosted sources whenever you make a new gem.

Of course, npm is unique in being privately funded. It doesn’t want you doing that.

Benefit of the doubt says that they thought they were publishing privately.

Going back to Ruby, you will fail a bunch of CI steps just by leaving defaults in place.

Hey, contributor to rubygems here, there's no source url for ruby gems specification. You can read more here: https://guides.rubygems.org/specification-reference/

You're likely thinking of bundler's source, but even then that doesn't apply to publishing a gem.

> Benefit of the doubt says that they thought they were publishing privately.

In what world is pushing your source code to a venture backed (therefore viral growth oriented) company who promote themselves with "npm Inc supports the JavaScript community by providing the registry where developers publish and share packaged open-source modules" possibly consistent with a view that "they thought they were publishing privately"???

Sorry, but I just don't buy that.

Somebody at the bank fucked up. It cannot possibly be npm Inc's responsibility to detect and somehow police that.

How much of them sending takedown notices was a desperate posturing of "omg please please please please don't use our code!!!"

I can't possibly see how they would possibly have any case.

If their code is proprietary, no one can use it. Even if they accidentally uploaded it to a public site.
I know that, but is the issue that companies are using the code or that NPM, Cloudflare, and Amazon are hosting the repo?
> If their code is proprietary, no one can use it. Even if they accidentally uploaded it to a public site.

Surely this depends on the terms under which they uploaded it. I would expect npm to have a legal structure in place under which code you upload for public use is also licensed for public use.

> I would expect npm to have a legal structure in place under which code you upload for public use is also licensed for public use.

Not how it works. For example, see the license field here:

https://www.npmjs.com/package/unlicensed

That would be the "terms under which they uploaded it"

NPM doesn't appear to have a "default license" though, so that would be "no license", therefore normal copyright law would seem to apply, and you can't make a copy of it, and more than you can copy a picture on a billboard or a blog post or whatever.

IANAL but if someone makes code publicly available (for 3 years). Then isn't there an argument to be made that its reasonable to make use of it? Probably not redistribute it, but use it at least. So I'm not even sure an explicit upload license would be required.
You seem to be arguing for an implied license; such things do exist—but the exact scope is often not obvious even to lawyers in the absence of case law covering very similar situations as to the kind of content and the use to be made of it.
My understanding is that it was based on custom/ industry norms. But yes a lot of lawyering would probably be involved.
If you leave your keys in your car for 3 years it's still illegal for me to take a joy ride in it. I don't personally believe in/support the concept of IP but in a world that does (like the US) it doesn't make sense to me that people being able to see your property for 3 years gives them the right to use it.
If you leave you car keys at my house for 3 years does the change the answer? With the car parked on my drive?

I'm not sure a car is the best comparison though.

How about a restaurant putting mint imperials by the cash register. Is it legal for patrons to take one?

With physical property, there is the concept of Squatter's Rights. With copyright, if you fail to protect it adequately (which I don't think is very well defined by the court system), then the IP in question can pass into the public domain.

I'm not sure what all rights (physical or otherwise) might be applicable here.

> With copyright, if you fail to protect it adequately (which I don't think is very well defined by the court system), then the IP in question can pass into the public domain.

This is not true. Not even remotely true. It is routine that a company notices someone using their copyrights after decades and then sues about it. Oracle is suing Google over code that was "unprotected" for a decade before they decided to sue. In Australia (I know, different country, but this is the same), Men at Work were successfully sued 29 years after they released "Land Downunder" because it has a two bar riff with similarity to a song written in 1928 [1].

As a side note, I see this all the time. What is it about this particular topic that people seem to (a) consistently confuse these things but more importantly (b) feel confident enough about ti to repeat the confused viewpoint with certainty to others?

You are probably thinking of trademarks.

[1] https://en.wikipedia.org/wiki/Down_Under_(song)

Are you maybe thinking of trademark? If you fail to protect a trademark then you can lose it.

AFAIK, you can selectively (or not at all) enforce copyright all you want and then change your mind later.

Dragonwriters answer was what I was thinking.

Are you thinking trademark rather that copyright? I'm not sure you can fail to adequately protect a copyright in that sense.

Has it been tested in court? :)
Yes, of course.
What if the public site states in their terms that they must be granted those rights on the uploaded material, and the actual copyright holder is the one who does the uploading (but accidentally)?
Absolutely not true. Anyone that lives in a country whose legal system does not respect their copyright can use it.
Basically every country has signed a treaty saying their legal system does respect them: https://en.wikipedia.org/wiki/List_of_parties_to_internation...

If you're saying any country where they don't respect it in practice, then sure.

And if it's protected as a "trade secret" and not a copyright (or patent) then you probably can use it without question.
Software is copyrighted "by default". You don't need to apply for copyright like you would need to do with a patent.
https://www.uspto.gov/patents-getting-started/international-...

USPTO explanation of difference between a Patent, Copyright, and Trade Secret.

I’m not sure how universally true that is.

When governments fail to redact documents, it’s on them.

If you “accidentally” talk to a reporter about your solicitor-privileged comms, it’s not privileged anymore.

This isn't an open question.

If you don't have a license from the copyright holder, you can't legally use it, except for fair use exemptions: perhaps you could write a blog post criticizing it.

Was there a licence attached to the files? What if there wasn’t
> If you don't have a license from the copyright holder, you can't legally use it, except for fair use exemptions: perhaps you could write a blog post criticizing it.
We're talking about code. Which is more like a recipe than a novel.

If Coca Cola writes down its proprietary recipe on their entrance "by mistake", I can definitely make use of it. Maybe I can't photocopy it for sale, but I can definitely re-use their previously-secret techniques.

I can even say I got it from them through their own error and have the exact same outputs for the exact same inputs.

Trade secrets aren't your secret anymore once you publish them.

All we know in this case is that copyright law was used as a tool to remove it.

> Which is more like a recipe than a novel.

Courts strongly disagree with you.

Thats only true for the US and the countries adhering to US copyright. It's not universally true
It's not "US copyright", it's several international copyright treaties, which 90% of all nations have agreed to: https://en.m.wikipedia.org/wiki/Berne_Convention

The few exceptions are where copyright essentially doesn't exist at all. Where it does, this is how it works.

Streisand effect.
Can't you recycle some old lawyer letters then?

Or a little more radical, why even bother with the lawyers? You can explain to them how it is, and if they won't listen, they can sue you. Then you spend some lawyer costs, they lose because the whole thing is ridiculous, and you get a 'cost conviction' or 'cost order' as we call it (kostenveroordeling, where you pay the winning party's costs to prevent abuse of the system) so they pay your lawyer.

So true. How many takedown requests per week do you think Apache.org gets from megacorps of the form "Our employee asked for help, and their debugging logs published our internal URLs. please delete this post and all replies" ?
Still made my day ;-)