News for hackers. Stuff that matters.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by macksd on Tuesday March 02, 2021 @10:29AM (#26316260)
One of the things that the recent Python cryptography debate has highlighted to me is how much we depend on this distribution of libraries like this. In that case, it's normal to just automatically get updates from a product and then one day, a whole bunch of software projects suddenly notice and, luckily, break (lucky, as opposed to being compromised). In this case, it's normal to just type a project name in install software, with very little vetting done by many people. I want to work on someone's web app, npm suddenly downloads the world. Who's actually audited all that? I know I haven't.

Not sure how we could fix it without slowing way down and doing a lot more work.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by ChrisMarshallNY on Tuesday March 02, 2021 @11:01AM (#26316676)
> Not sure how we could fix it without slowing way down and doing a lot more work.

Unfortunately, this is pretty much the only way, besides the "walled garden" approach.

I am often derided as being a "grumpy old control freak." They def have a point, but I am very, very leery of bringing code into my projects that I don't understand, and stepping through source takes almost as long as writing from scratch.

Most dependencies cover a wider range of functionality than the narrow application that we seek in our individual projects, so, to truly understand the dependency, we need to examine all of its faces.

I recently had to yank a dependency out of a project that I'm developing, because it had a regex bug that caused memory leaks and random crashes in worker threads. It would have been way too difficult for me to figure out what was happening, so I removed it, and wrote my own functionality that is not as good, but doesn't crash my application. This is the kind of behavior that gets me scorn. I'm supposed to keep the crash, and shrug.

So, yeah. I guess I am a grumpy old control freak...

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by mcguire on Tuesday March 02, 2021 @01:39PM (#26318726)
Can you believe how much work it is to even get repeatable builds out of these systems and people?
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by carapace on Tuesday March 02, 2021 @04:17PM (#26320884)
Random tangent: I was poking around your blog and found the entry "1985 Dijkstra interview"[1] and I was struck by this line:

> The net effect of it seems to be that a full system for really acceptable programming will be at the same time a full system that will suffice for the description of constructive mathematics.

He said that in '85!? Wow.

[1] https://maniagnosis.crsr.net/2007/10/1985-dijkstra-interview...

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by a1369209993 on Tuesday March 02, 2021 @05:38PM (#26322094)
> a full system for [knowably-non-buggy] programming will be at the same time a full system that will suffice for the description of constructive mathematics.

That's basically the Curry-Howard correspondence[0], which was first explicitly stated in 1980.

0: https://en.wikipedia.org/wiki/Curry-Howard_correspondence

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by h2odragon on Tuesday March 02, 2021 @11:16AM (#26316864)
> stepping through source takes almost as long as writing from scratch.

"But why would you do that?" and "But thats the point of using those libraries!" right?

when you're the only one that can find the heisenbug and fix it; your effort and the need for it aren't evidence of over-reliance on dependencies. They are an argument for re-implementation from scratch in brand new, clean, safe technologies!

you may have started a howl

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by ChrisMarshallNY on Tuesday March 02, 2021 @11:40AM (#26317157)
Well, the classic argument for open-source, is that the "customer" can always pop open the hood, and look at the gears and whatzis.

This is seldom actually done. More frequently, customers will find bugs, and fix or report them, thus, improving the tool for all users.

In this one case, it was not reasonable for me to do this. The application that I'm developing is closed-source (for now), and I was in the middle of a pretty massive refactoring job. There was no way that I was going to take a couple of days to try to nail down a random memory leak/thread safety bug in someone else's code, when I could simply use the Apple OS tool to do something similar, and I knew it would be safe.

I definitely could have figured it out (given time). I'm a very good debugger, but it would have been an unacceptable branch in my workflow. I have a pretty full dance card, and this was not on it. Thread safety issues can be a pain to track down, and they are like cockroaches; for each one you see, there are a dozen more, behind the drywall.

I wasn't about to raise a ruckus about it. I suspect that the tool works fine in standard main thread apps, and my application uses worker threads that originate from things like network callbacks. The author won't shut down the tool, because one random person with a specific workflow has an issue. I have managed open-source projects, and know what it's like to be on the other end of that crap.

The biggest issue with dependencies is trust. That's why walled gardens are attractive. There's a chain of responsibility, and some kind of accountability baked into them. Even then, some of these libraries can get compromised, or sold off to nefarious actors. Also, I suspect that many of these SDKs and dependencies are really "first hit is free." They can make us dependent upon a person, company, or whatever, that does not have the best interests of our user at heart.

I tend to rely on manufacturer API/toolsets, and even then, I'm really careful. Some of the SDKs that ship with devices and services can be...questionable. But if I find myself blaming the compiler for an issue, I can be reasonably sure that the actual problem is mine. If I am using a blackbox tool that sits between me and the iron, it can be difficult to figure out where the problem lies.

Just a couple of days ago, I had to change the hosting provider that runs the backend for the application that I'm developing. I wrote that backend, and there was definitely some kind of bug, but the hosting provider decided to introduce a new "can't be switched off" inline cache that completely broke interactions with the backend, so I couldn't find my bug. If the backend had been a server that I don't control, it could have taken many more days to even figure out that the bug was in the host, report it (or diagnose it), and then wait for the inevitable back-and-forth before it was addressed. Since my primary work is the frontend app, that would have meant a huge delay. I figured out the cache issue, because I am intimately familiar with the backend, and could easily diagnose problems, using the classic "divide and conquer" methodology. Once the hosting provider was switched, it took me half an hour to find and fix the bug.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by inetknght on Tuesday March 02, 2021 @01:30PM (#26318608)
> I could simply use the Apple OS tool to do something similar, and I knew it would be safe.

Even that assumption is being eroded

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by ChrisMarshallNY on Tuesday March 02, 2021 @01:33PM (#26318652)
Sadly, you have a point.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by da39a3ee on Tuesday March 02, 2021 @11:09AM (#26316769)
I don't think that understanding your dependencies is a reasonable criterion (the intellectual scope of your dependencies should be beyond your intellect for all but very simple projects). Furthermore I think that your approach essentially rejects the good engineering/design principles of modularity/separation of concerns (it is _good_ to black box things).
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by xapata on Tuesday March 02, 2021 @11:16AM (#26316858)
Depends on how much understanding you're talking about. I don't need to know how to build an x86 chip, but as an experienced and educated professional programmer I should probably have a decent sense of which kinds of instructions are time consuming and which aren't, how the cache works, etc.

Abstractions are leaky. You should strive to understand where your black box is transparent.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by mikem170 on Tuesday March 02, 2021 @12:20PM (#26317697)
>I don't think that understanding your dependencies is a reasonable criterion

I agree, I've never gone as far as reviewing/understanding source code for all the libraries I use. Might be nice to have the time ;-)

>it is _good_ to black box things

I trust that you are talking about using other people's black boxes, as opposed to reinventing your own?

I would say that there is some element of risk in trusting a library that someone else made, particularly over time as systems need to be upgraded. Will there be problems during or after an upgrade? Is the whole dependency chain upgradable? Will the upgrades work on all operating systems in use? Are there relevant corporate policies and/or whitelists that might interfere with or slow down upgrades?

Personally I pay close attention to the dependencies I'm using in a project, especially long-lived projects. I find it super aggravating when something I've tested and deployed breaks a couple years later after routine upgrades due to some kind of drift problem to do with a dependency.

How much benefit am I getting by using the library? Best is using base library that comes with the language. Next best would be a well maintained third-party library with a good reputation in the community, one that doesn't have too many dependencies itself. Am I happy with the api of the library, and its documentation? Is is reasonably easy to approach given its functionality? Is the library available as a package in the operating systems I'm working with? How long has it existed? How stable has it been over time? Is the library a good fit for what I am doing, or do I have to bend my code to use it as intended? Do I have multiple libraries to choose from? Can I use the library in such a way that I can change my mind later?

I think there is value in trying to minimize the use of external libraries, up to a point.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by andrewzah on Tuesday March 02, 2021 @02:16PM (#26319167)
"Might be nice to have the time ;-)"

It's not about having the time, but -making- the time. For the most part we simply do not prioritize looking into the source code of the libraries we use, to any meaningful degree. (I'm guilty of this for sure). Hence things like leftpad and the many other instances of dependency controversies.

In an ideal world we [and our employers] would put emphasis on inspecting the huge amounts of code we pull in and allocate time for it.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by alisonkisk on Tuesday March 02, 2021 @03:29PM (#26320194)
How would you ever have time to write new code?
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by detaro on Tuesday March 02, 2021 @03:37PM (#26320290)
if you don't write new code, you also don't pull in new dependencies, and have time start new code ;) And cost to dependencies makes you optimize what you pull in.

(Cost to dependencies doesn't have to be just review time. E.g. in my embedded software projects, the calculus for "will we need to update this" looks very differently than it would for your typical web app. And extracting interesting bits from libraries and including only that into the main project is maybe more common, reducing the surface of a dependency - which would be a bad idea if you expect frequent changes, but these projects typically don't)

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by ChrisMarshallNY on Tuesday March 02, 2021 @04:57PM (#26321537)
I have plenty of time to write new code. I write code (often lots of code) every single day.

I don't mind dependencies, but I won't use them for anything mission-critical, unless I spend a great deal of time vetting the dependency. That might mean auditing the code, but more often, it is auditing the coder.

The main thing is, is that we need to really think about anything we add to our precious project, from outside. In my experience, people seem to be alarmingly casual about this.

Good results can be building very big systems, in a very short period of time, using very few resources, and everything works great.

Bad results can be building very big systems, in a very short period of time, using very few resources, and everything works great.

Until it doesn't.

For example, an upgrade introduces things like renamed CSS hooks, or introduces thread safety issues. A PR isn't vetted properly, and license-problematic code, or malicious code is introduced into the system. Maybe the author has a car accident, and can't manage the library anymore. Maybe a dependency down the chain gets taken over by someone that uses...let's say "solarwinds123" as the password for their CI server, and they get pwn3d, but, since they are buried three levels down, no one in the main dependency realizes what happened, and so on. Maybe you get to a point where you outgrow your backend, and need to change to a more robust or secure backend, but the SDK you are using has you addicted to the initial backend that you selected, when the project was still in the crib, etc.

It should not be a casual decision.

In my original post, I talk about having to yank a dependency.

It was a phone-number parser. If you know anything about phone numbers, parsing them is non-trivial. Apple has a built-in utility (a scanner for URLs, phone numbers, addresses, etc.), but that is not as effective as the parser I imported, which had a fairly good pedigree. I looked at the code, and checked out the author, and it looked good.

The issue that I encountered was most likely (can't be sure) a thread-safety issue. I ran parses in non-main threads, and noticed memory leaks, and random crashes.

I do not suffer memory leaks or crashes of any kind, in my apps, so it had to go.

Phone number parsing wasn't a dealbreaker. Because it was a dependency, its application was fairly encapsulated (I always encapsulate external dependencies -just plain old horse sense), so I can go back and maybe reinstate it (if I can fix the issue, or use it only in main threads), or add a different one in the future. In the meantime, the Apple tool is fine for my development.

The backend for the project, on the other hand, is mission critical, so I wrote it myself. I am not a backend expert, but there are some things that I needed assurance on, that no backend engine can give me. It's highly encapsulated and layered, so future efforts can replace it. I can tell you that whatever it gets replaced with, will need to meet my exacting criteria.

My current project has one external dependency (it has quite a few, that I wrote): A keychain abstraction. It's very simple, and is actively maintained. I've used it in other projects for years.

The dependencies that I wrote are pretty intense; even the small ones. The testing code dwarfs the implementation code in all of them. One of them is an SDK for a pretty vast system, where I was the original architect, but has since passed on to a new team that has my complete confidence; so I guess you could also call that an "external" dependency, but one that I know very, very well.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by lordlimecat on Tuesday March 02, 2021 @02:32PM (#26319395)
A good black box relies on the assumption that the inputs / outputs are well documented and true to their spec.

This is a very unsafe assumption, at least until we invent a programming language that disallows bugs of any class.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by alisonkisk on Tuesday March 02, 2021 @03:29PM (#26320182)
What's the point of a philosophy that is impossible to live up to. Nobody audits a substantial fraction of their dependencies.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by a1369209993 on Tuesday March 02, 2021 @05:49PM (#26322224)
> Nobody audits a substantial fraction of their dependencies.

I do! In fact if we exclude the language implementation itself[0], a plurality of my projects have NaN% of their dependencies fully audited.

0: ie, compiler, hardware, etc; if you object to this, please do explain how to eliminate these dependencies; I'm quite interested.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by bpt3 on Tuesday March 02, 2021 @04:13PM (#26320841)
> What's the point of a philosophy that is impossible to live up to. Nobody audits a substantial fraction of their dependencies.

It's a choice to be ignorant of your dependencies, not a law of nature.

The fact that most people don't audit code they depend upon is a problem to be fixed, unless the underlying code is fixed first.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by jjav on Wednesday March 03, 2021 @05:38AM (#26326768)
> it is _good_ to black box things

... to teams you can 100% trust and whom are in the same sphere of responsibility. So yes, take a binary library blindly from the team down the hall who reports to the same VP.

From an unknown rando on the internet, not so much.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by tux1968 on Tuesday March 02, 2021 @10:39AM (#26316385)
The only practical way is to have a centralized vetting organization that can give a trusted stamp of approval to signed packages. That would still slow things down, but at least wouldn't require duplication of work by everyone on a massive scale. You could outsource your vetting work to a distribution you trust.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by artful-hacker on Tuesday March 02, 2021 @10:47AM (#26316489)
I was trying to find a solution to this problem for my organization and came across https://tidelift.com/. I like some of their ideas and think it's a solid path forward at chipping away on this issue.

https://libraries.io/ is a project of theirs I use quite often when vetting third party dependencies for our organization.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by shrimp_emoji on Tuesday March 02, 2021 @12:54PM (#26318113)
The only practical way is to run all software in sandboxed containers that statically link everything they need and cannot harm the system via bugs/exploits from outdated/compromised libs.

In the past, there wasn't much software or much memory, and software was simple. Now, memory is plentiful, there's too much software, and software is too complex. A central authority doesn't scale. Fixing our naivete about how much to trust software does.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by vel0city on Tuesday March 02, 2021 @02:57PM (#26319759)
Software that I can't put data into or take data out of isn't very useful. You can mitigate the splash damage something could do and reduce the attack surface, but at some point I'm probably going to be feeding that process some files or data stream and I'm going to have it write out some files or data stream. Those data entry and exit points are still exploitable, or acting on the data stream could be harmful. Sandboxing is good to do, but ultimately isn't the solution to the problem of malicious code. Otherwise its pretty much just a space heater.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by contravariant on Tuesday March 02, 2021 @06:56PM (#26322944)
I can kind of see what you're getting at but a pure function can both accept and return data without any risk of this data leaking anywhere unintended.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by vel0city on Tuesday March 02, 2021 @10:38PM (#26324437)
Data leaking isn't the only thing you may be worried about. What about a random number generator designed as a pure function that skews a certain way reducing your cryptographic integrity? What if what looks like a pure function from the outside you're using for some range estimate on some ballistic payload is able to detect its in a live fire scenario and changes its outputs leading to inaccurate detonation? We're talking about malicious external packages/libraries and what not coming in, assuming everything is a pure function in the compiled black box of obfuscated code probably isn't a winning strategy on keeping your system secure. Of course, everyone's threat profile and the risks of failure vary greatly based on the application being deployed.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by tux1968 on Tuesday March 02, 2021 @01:06PM (#26318285)
You're definitely right that decreasing the attack surface will be an important element to improving the situation, but it doesn't really solve the problem completely. Software will always need operational room to do anything useful and in so doing will still offer an opportunity for exploitation.

Increasing the trust we are able to place in the tools and libraries we leverage isn't a complete solution either, but it will have to be an element. Currently we've got nothing but blind faith and crossed fingers.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by JulianMorrison on Tuesday March 02, 2021 @10:50AM (#26316531)
The issue that runs into is a mirror of the one raised by the pyca/cryptography business. For which CPU and hardware architecture should they be verified? On which OS? With which set of dependencies, including dependencies on non-Python compiled libraries?

Presumably all of those will need to be verified as well, and the problem recurses.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by freeone3000 on Tuesday March 02, 2021 @10:56AM (#26316615)
Every different CPU architecture and OS architecture is a different package. Software distributions already know this. The individual packages need to be verified.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by vel0city on Tuesday March 02, 2021 @02:56PM (#26319735)
At least with Python, this is true only if you're installing pre-compiled wheels which is quickly become more and more the norm. For a while though several packages were compile on install so you wouldn't necessarily have a different package per architecture/OS combination.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by freeone3000 on Tuesday March 02, 2021 @03:05PM (#26319855)
You don't have a different package name, but you for sure have a different package. Take, for instance, the keyword "long". 64 bit on amd64, 32-bit on armhf. So even source distributions to be compiled locally differ based on target, even if they have the same coordinates in pypy.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by vel0city on Tuesday March 02, 2021 @04:05PM (#26320727)
I agree the resulting binaries will be different but I disagree that these are then different packages. The package is whatever the distributor distributed it as. They distributed it as source, which you took and compiled to your local binary version. With "The individual packages need to be verified", and each resulting different binary being uniquely a different package, this means the package/repo maintainer of a source package would need to verify it for every single platform which compiles C and every potential compiler and every potential set of flags for the compiler as each set of platform/compiler/flags could result in a different binary and thus different behavior.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by freeone3000 on Tuesday March 02, 2021 @04:56PM (#26321509)
Yeah, if I were setting up a verification service there's no way I would verify source code instead of compiled binaries.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by adolph on Tuesday March 02, 2021 @12:40PM (#26317938)
That sounds like it would have the app store problem. If you are successful, you are a monopoly target. If you miss an attack, you are to blame. If you don't approve fast enough, you are blocking.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by tux1968 on Tuesday March 02, 2021 @01:09PM (#26318331)
The entire point of such an organization would be to accept the blame if an attack was missed. But there should be no natural monopoly since anyone could offer this vetting service. And as an end user there would be nothing preventing you from circumventing the repository of such a service (except for the risk you'd be taking on for yourself).
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by adolph on Tuesday March 02, 2021 @01:32PM (#26318639)
Scapegoat as a Service?
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by tux1968 on Tuesday March 02, 2021 @01:43PM (#26318776)
Sure, you could look at it like that. But their only value would be if they're never (or at least very rarely) actually called upon to act as a scapegoat. All the incentives would be for them to do their job and keep compromised software out of the ecosystem. Of course nobody is perfect, but they couldn't be flippant about it and survive.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by uranusjr on Tuesday March 02, 2021 @02:05PM (#26319042)
What are the incentives? I honestly can’t tell.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by tux1968 on Tuesday March 02, 2021 @02:25PM (#26319288)
The only reason for such an organization to exist is to be a clearing house for software; adding a stamp of approval that it is safe and hasn't been compromised by nefarious actors. Such an organization might be funded by a trade association, industry sponsorship, or direct fees to end users. But whatever the case, it would be strongly incentivized to fulfill its mandate or else lose credibility, reputation, influence, and financial rewards.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by matheusmoreira on Tuesday March 02, 2021 @01:15PM (#26318409)
> Who's actually audited all that?

That's the point of software distribution maintainers. They are actual humans who must essentially sponsor a project before it becomes a package in a repository. They take responsibility for the packages they maintain. Users trust these humans since they usually don't make mistakes like letting literal malware into the software repositories.

Most modern languages are deliberately designed to be incompatible with this model. They optimize for developer ease of use and developers don't like getting approval from other people in order to publish their code. So they make their own little isolated worlds where everyone can upload anything they want.

Honestly it's amazing it took this long for people's trust to be exploited.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by alisonkisk on Tuesday March 02, 2021 @03:31PM (#26320214)
Languages aren't incompatible at all. People choose to use excessively liberal package-mangement systems.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by ryukafalz on Tuesday March 02, 2021 @12:49PM (#26318047)
> Not sure how we could fix it without slowing way down and doing a lot more work.

You restrict what your dependencies can do in the first place, so that if they're malicious (or just buggy) the scope of what they can do is limited. This doesn't eliminate the risk entirely - after all, it's possible for a library to introduce vulnerabilities just by doing its job incorrectly - but it massively limits the scope of what you'd need to audit. Right now, any dependency can do anything, so you'd need to audit all of them.

See POLA Would Have Prevented the Event-Stream Incident[0] for more explanation and LavaMoat[1] for an example of tooling that's trying to tackle this problem.

Now, this might count as "doing a lot more work" since it's admittedly not quite as simple as just typing in a project name. It's much less work than rewriting everything from scratch though. :)

[0] https://medium.com/agoric/pola-would-have-prevented-the-even...

[1] https://github.com/LavaMoat/lavamoat

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by hanniabu on Tuesday March 02, 2021 @11:10AM (#26316781)
> Not sure how we could fix it without slowing way down and doing a lot more work.

Can create a market for library audits that the library's team would pay for and provide "vetted" tags for libraries that have audits on minor updates.

Things can continue as they are for smaller libraries, but any library that's used in more critical areas should have no issue finding audit sponsors.

This would also create in incentive for somebody to develop automated auditing tools.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by BiteCode_dev on Tuesday March 02, 2021 @11:19AM (#26316890)
That's what anaconda is.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by TheCabin on Wednesday March 03, 2021 @06:32AM (#26327079)
Many people here say that slowing down is a must -- and I agree it's probably the best solution -- but surely there are more approaches we could think of:

* Not allowing packages with similar names to popular ones

* Not allowing packages creation to be anonymous (in the extreme case you would require to validate your passport or similar)

* Automatic detection of malicious code

* Central auditing organization ...

This is just on top of my head, there must be many more ideas.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by jjav on Wednesday March 03, 2021 @05:33AM (#26326741)
Well you can't, slowing down is a must. Blindly taking packages of executable code to be embedded in your code from anyone and everyone in the world who can publish a dependency is very flawed. It only mostly works because most people are nice most of the time but that's not a process one can trust.

I understand the desire for these free-for-all package distributions where every tool has it's own library downloader and anyone can publish anything... but the model is inherently incompatible with security.

On the provider side, there needs to be a strict process of validation and code reviews to get any code changes into a public library. On the consumer side, there needs to be the will to take personal responsibility to curate everything that is imported and minimize dependencies.

There's no shortcut to secure code.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by alfiedotwtf on Tuesday March 02, 2021 @01:31PM (#26318620)
This is why I absolutely hate not pinning down versions/hashes.

For example, with `cargo`, let’s say a library I require passes a security audit. However, because a library it requires, or one of its dependencies requires doesn’t pin down a specific version but instead just requires “latest” or “2.1.”, my security audit is for naught given that malware can slip in any time for 2.1..

That goes for testing too. I’ve tested my software etc, but sometime down the line a transitive dependency updates and adds a bug. Now my software that i haven’t changed, is broken.

Software requirements without pinning is a code smell.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by gpm on Tuesday March 02, 2021 @04:28PM (#26321054)
With Cargo, the final binary (or artifact if you're building a .so/.a/.dylib/...) has a `Cargo.lock` file that pins every recursive and non-recursive dependency. If you audit the packages in that, you've audited every dependency that is used in your project, and they will not change unless you yourself explicitly tell them to.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by alfiedotwtf on Tuesday March 02, 2021 @08:13PM (#26323479)
Oh! TIL, thanks!
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by remram on Tuesday March 02, 2021 @04:46PM (#26321334)
If your direct dependencies pin their dependencies, then you will definitely end with conflicting versions for your transitive dependencies.

This might work in environments like Node, where each library having their own private versions of their dependencies is acceptable, and Rust/Cargo in some situations, but doesn't work in environments where only one version of a package can be present (e.g. Python) or you care about the total size of the dependencies.

Also if you're auditing, wouldn't you audit all dependencies? What does it matter whether they are pinned by your direct dependencies, wouldn't you yourself pin down the transitive dependencies after auditing them?

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by alfiedotwtf on Tuesday March 02, 2021 @08:14PM (#26323484)
> Also if you're auditing, wouldn't you audit all dependencies?

What’s the point of a transitive dependency can pull the rug out from under your audio with a single update

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by remram on Wednesday March 03, 2021 @12:33AM (#26325135)
Don't update without auditing the new versions? I don't understand.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by ryanmarsh on Tuesday March 02, 2021 @10:38AM (#26316379)
Who's actually audited all that?

I'm sure it's insufficient but you asked who audits all that (re: npm) well, apparently somebody.

https://docs.npmjs.com/cli/v7/commands/npm-audit

The audit command submits a description of the dependencies configured in your project to your default registry and asks for a report of known vulnerabilities. If any vulnerabilities are found, then the impact and appropriate remediation will be calculated. If the fix argument is provided, then remediations will be applied to the package tree.

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by jhardy54 on Tuesday March 02, 2021 @10:42AM (#26316422)
This provides a list of well-known vulnerabilities, it doesn't actually audit the source code to find unknown vulnerabilities.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by JMTQp8lwXL on Tuesday March 02, 2021 @11:03AM (#26316707)
The business case for accepting the risk of downloading untrusted software has proven time and time again to be worth it. Without NPM modules, time to deliver would be much, much longer. If it was that bad of a problem, we would've collectively moved away. Many companies privately invest in their own registries that proxy to NPM, with an intermediary security layer. The maintainers of NPM have shown they'll cleanup the left-pad's and major security issues when they occur.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by goatinaboat on Tuesday March 02, 2021 @11:10AM (#26316786)
Without NPM modules, time to deliver would be much, much longer.

This is a circular argument. “We chose a language that has millions of tiny dependencies now we need a tool to manage millions of tiny dependencies”

Re:3500 packages uploaded to PyPI, pointing to a malicious URL by JMTQp8lwXL on Tuesday March 02, 2021 @01:07PM (#26318291)
If you must ship JavaScript for the web, you don't have much of a choice in languages (you might choose a superset like TypeScript, which is still distributed via the NPM ecosystem). For server-side code, agreed. You don't have to choose Node.js or JavaScript or NPM there.
Re:3500 packages uploaded to PyPI, pointing to a malicious URL by ohiovr on Tuesday March 02, 2021 @08:32PM (#26323613)
Would anyone pay for a curated service?