568 points · by edward · 7y ago · 220 comments
What it did was ask me to "log in" (there was no prompt to sign up), which I did with our internal credentials. It also asked for an email address, which in retrospect was foolish of me to provide, but that was the only indicator that something was not right. It did not tell me where I would be publishing to.
When it was done it said the package was published. I checked the internal repository and it was not there. Instantly felt that horrible feeling in my stomach that everyone knows. I went to npmjs.com and found out that it had helpfully created an account with the internal credentials I provided, the credentials that were given in a prompt that said "npm login".
What saved me was that the package was inside an organisation ("@foo/bar") and those are not free on NPM, so the package was not published, even though Yarn said so. The user account was created, though, so I had to recycle that password and send email to NPM support to get the account deleted (there is no way to delete your account yourself, sadly).
The moral of this post is that when I saw this tweet I did not laugh at the company's foolishness in publishing internal code on NPM, because I almost did that myself and saw how easy the mistake is to make. (Of course, the rest of the tweet with the DMCA stuff is foolishness.)
Explicit vs. Implicit : always choose explicit if accidents can cause people serious pain. npm login that is secretly npm "create account" is a serious anti-pattern. And npm publish -> npm login -> npm create account is a consequence of that.
(Public) Orgs _are_ free on NPM (at least nowdays) so maybe even that wouldn't have saved you.
It's an easy mistake to make. What is concerning is that the bank didn't notice for three years... I feel like that should have been caught a lot sooner.
Also, a .rc file (package manager chosen by the team) with a private registry that refuses to publish unless done automatically by the pipeline set in the root of every project.
The only reason I find it understandable how it could happen at a major bank (these days, they should have a sizeable team that takes care of security measures like I described) is that this was 3 years ago. Publishing to private registries was relatively new back then, so people didn't have proper publishing workflows yet.
I mean... I guess mistakes can still happen. But on a scale of 1-10, I would find such a mistake far less excusable today considering the circumstances. Small, inexperienced team, maybe constant deadline pressure - more excusable. Duh...
This is how we do it. Publishing is locked down to specific service accounts, with credentials set up in a CI environment with locked down build configurations. Publishing to the internal registry is not possible unless you have these credentials, and you don’t. There’s a whole process for retrieving keys. Publishing to the internet isn’t possible due to a firewall just killing those requests dead. You could probably do it via a proxy, but you’d break your contract and probably be fired if not worse.
People complain about the locked down build configurations, until they need help at which point standard build configurations mean they actually get support, as opposed to “good luck; have fun!”
Source: I work for a major bank. (Presumably not the one this story is all about!)
For the original tweet's company, there was probably some kind of incompetency involved in not noticing that the code was public for years. But I can't comment on that further as I don't know the circumstances. I only wrote my anecdote about the accidental publishing side.
Or something to that effect. Or maybe companies can just pony up for NPM Enterprise which fits their use case.
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.
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.
> "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".
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.
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.
You're likely thinking of bundler's source, but even then that doesn't apply to publishing a gem.
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.
I can't possibly see how they would possibly have any case.
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.
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.
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.
I had also reached out to our client contact. They contacted the CMS company, provided them with the license information, and then switched to another CMS.
He was also concerned that we were letting people 'View Source' our web pages and stealing our IP.
...and here is where the DRM advocacy comes in. Don't let them ruin the Internet...
Just sayin.
So, good job.
The problem NPM solves isn't a particularly interesting or challenging problem to solve if you don't try to solve it at scale. They'd just build their own. Then for the couple of packages that are hard to replicate, they'd find a way to sign some papers to get access to the code and push it to their own registry. For everything else they'd just rewrite it from scratch. Short of things like React, it's not all that hard for places with the resources of these big corps to rewrite bundlers, web servers, and utility libraries.
Not only do you get additional security for 2FA, you also get a prompt for the TOTP pin that makes you question what and where you’re publishing.
Surely in a bank, when publishing, the decisions aren't down to a single dev. Either many people made a mistake together or many people made lots of small mistakes separately that added up to one big one??
FWIW, I don't know, I'm a small time potter, just how I imagine things happen in banks (I do know a couple of devs who work/worked for banks).
Source: https://twitter.com/seldo/status/1105157348560007168?s=09
It’s certainly true that some security practices within our organization seems more like security theater than anything else, but overall I think they have pretty reasonable standards and requirements set. It is very true though that the culture is almost entirely focused on compliance more than anything else, so there’re few proactive measures taken by teams. Lord knows no team I’ve ever seen outside of security wants to budget for it. Maybe it’s a damned if you, damned if you don’t kind of situation. If you don’t set compliance regulations you’ll get no security (move fast and break things, yay!) but if you do you end up with people ticking boxes saying “the thing is secure and stuff yo” and then play the blame game when it isn’t.
My feeling though, having worked with top tier banks in the financial industry for the last 8 years or so, is that more people are competent than not, but process stifles creativity and drive a lot of the time. It’s a very special kind of environment to work in.
"Stupidity" is having ignorance about a field but pretending not to.
These lawyers may have 7 years of law school education, but they are still "stupid".
npm install goldmansachs
Maybe $35/byte. Then the lawyers could haggle, get it reduced to $35/non-white space byte, and feel like they accomplished something.
If someone finds a module of BankX's boring backend code, what is the risk/problem for the bank?
Another thing is the code itself, you don't want competitors seeing your implementation if you feel that it gives your company an advantage over others. There may be data structures or algorithms that are internal company knowledge only and defined in the code.
Tweet thread says it's a react packaged which means it's probably usually transpiled and minified, so not technically available in its original form in its distributed application.
I was upset about it when it was introduced, but now I start to see the point...
SMH.
> (From npm tos) Your Content belongs to you. You decide whether and how to license it. But at a minimum, you license npm to provide Your Content to users of npm Services when you share Your Content. That special license allows npm to copy, publish, and analyze Your Content, and to share its analyses with others. npm may run computer code in Your Content to analyze it, but npm's special license alone does not give npm the right to run code for its functionality in npm products or services
Private npm repositories are an entirely different beast, and like GP mentions, there is no great option here.
That includes tarballs on http, git repos and even freaking local directories.
For companies where putting packages on smb mount is treated as non-enterprisey, npm have "npm enterprise" offering: https://www.npmjs.com/products/enterprise
EDIT - I see what you are saying - your own registry with browser and all.