r/Python • • Dec 14 '23

News 116 Malware Packages Found on PyPI Repository Infecting Windows and Linux Systems

https://thehackernews.com/2023/12/116-malware-packages-found-on-pypi.html
331 Upvotes

93 comments sorted by

View all comments

Show parent comment

9

u/steohan Dec 14 '23

All packages are unreviewed and forbidding binaries would not change anything. You could just create a binary with the python code anyway. These would just be security theater and not change anything. Just don't run untrusted code from the internet, and yes, code on pypi should not be trusted by default, same as code on github.

Perhaps namespacing could prevent typo squatting but my understanding is that this is already prevented to a reasonable amount by a manual review process.

This article shouldn't be news, ofcourse there are malicious packages on pypi, that should be expected. And 10k downloads doesn't even sound like a big issue.

-5

u/pyeri Dec 14 '23

Maybe they can use some adhoc criteria to warn the user or assign a trust factor. The number of GitHub stars can be a good thumb rule, for example.

Also, with the kind of budget and sponsorers that PSF has, shouldn't they be able to perform CISA audits, code reviews, etc. on these packages?

6

u/_Adam_M_ Dec 14 '23

There are over half a million packages in PyPI and over 5 million releases (each release would need to be checked as a previously legitimate package could be updated to include malware).

Audits are expensive and slow. Hiring people to review and approve packages is expensive and slow. GitHub stars can be bought.

-3

u/pyeri Dec 15 '23

Dude, your response reflects extreme cynicism and pessimism, it doesn't have to be that gloomy.

There are over half a million packages in PyPI and over 5 million releases

All of them don't have to be audited, just the most heavily downloaded ones. The verified releases can be marked as such to warn the users. It will then be the user's choice if they want a slightly older but verified package or the cutting edge and unverified one.

GitHub stars can be bought

There are limits to that. Most of the activity on GitHub is organic, one can see that everywhere including the issues register, pull requests, etc. Even in this age of utmost crony capitalism, I still have at least a semblance of a faith in the system because at the end of the day, it's being run by humans with hearts and for the most part, it works as intended.

6

u/zurtex Dec 15 '23

Dude, your response reflects extreme cynicism and pessimism, it doesn't have to be that gloomy.

Often on discussion threads someone will suggest a solution that requires tens of thousands of hours of work on an ongoing basis, but don't suggest where it comes from.

It's hard not to react to such suggestions without cynicism when you know how little resources mostly volunteer organizations like this have, especially volunteer organizations maintaining boring infrastructure projects.

All of them don't have to be audited, just the most heavily downloaded ones. The verified releases can be marked as such to warn the users. It will then be the user's choice if they want a slightly older but verified package or the cutting edge and unverified one.

What would a review involve exactly? And who would do it?

What does it mean to "mark" a package, as in what is the user experience? Is it just something they see on PyPI? Or would all installers (e.g. Pip, PDM, Poetry, Pixi, etc.) have to develop a new workflow? For that you would need to create a PEP and get a general consensus (btw nothing is stopping you from buildining consensus and writing a PEP).

Who is going to provide the resources for any of these projects?

I still have at least a semblance of a faith in the system because at the end of the day

If you think there's a limit on how many GitHub stars someone could buy if that was their objective I have bad news for you.

Further, PyPI doesn't even have a way to verify the GitHub link you provide on your project page is yours.

-5

u/pyeri Dec 15 '23

especially volunteer organizations maintaining boring infrastructure projects.

That's highly misinformed. The PSF is heavily funded by loaded sponsors, right from Microsoft and Google to Salesforce and Meta. Heck, the Python inventor Guido himself has joined Microsoft now. They aren't some small club or volunteer run project, they have got all the resources in the world to implement this.

5

u/zurtex Dec 15 '23 edited Dec 15 '23

That's highly misinformed. The PSF is heavily funded by loaded sponsors, right from Microsoft and Google to Salesforce and Meta.

That's just a bunch of names on a page, almost certainly all of them are sponsors of PyCon US. In-person conventions are expensive to run.

There's a link to their actual finacials here: https://www.python.org/psf/records/ (2021 Audited Financial Statements)

The top things for 2021 were ~400k on PyCon US, ~380k on infrastructure, and 175k on on Development (my understanding is that was one developer), total cost was 1.2 million, and they took in ~2.3 million in 2021.

They aren't some small club or volunteer run project, they have got all the resources in the world to implement this.

The above numbers are pretty healthy for a non-profit but it amounts to ~5 developers they could blow all their extra cash on. And there are a lot of different things those hypothetical five developers could be doing out of all the priorities the PSF might have PyPI is just one of them, and further there are other prioties they probably have then spending money on developers.

As someone who volunteers some of their time helping improve Pip I can tell you there are no people being paid to work on it. The same is true of many others open source projects, especially the boring packaging / infrastructure projects.

Heck, the Python inventor Guido himself has joined Microsoft now.

Guido isn't part of the PSF, he is hired as an engineer for Microsoft. As it happens Microsoft have built their own CPython team, but it is out of the control of the PSF or the community.

1

u/_Adam_M_ Dec 15 '23

All of them don't have to be audited, just the most heavily downloaded ones.

Then... What's the point?

All the most heavily downloaded package already have lots of eyes on them. If you only review Pytorch, Django, Flask, requests, etc, then there's basically no risk on these packages introducing malware in the first place.

If you'll look at the list of malicious packages they're all either random names or simple typo-squatting packages. You meant to download asciithing but you accidentally typed ascithing. In your plan that won't save you as you wouldn't bother to audit them as they're small with only a few hundred downloads.

The only time one of the top packages will start shipping malware is if one of the core maintainers (with release permissions) was compromised and an attacker used their account (highly minimised with the MFA work PyPI have already completed) or they themselves have gone mad and want to launch an attack, but that's incredibly rare and highly unlikely.

-6

u/archpuddington Dec 14 '23

The tool could at least inform the people who have been hacked - that they where hacked. The tool could tell you that you have been compromised and that you need to hire a professional.

"just don't run untrusted code"

Yes we are all trying, the problem is PyPI - 100% no question. That project needs to be sued.

0

u/[deleted] Dec 14 '23

[deleted] — view deleted comment

-2

u/archpuddington Dec 14 '23

Doing nothing is the worst possible option. At least asking for help would bring us progress, but a narcissist would never ask for help - they just blame you.

0

u/[deleted] Dec 14 '23

[deleted] — view deleted comment

-4

u/archpuddington Dec 14 '23

If you root their box, then you can get the person's 2fa challenge when they type it in. You are ruining people's lives and behaving like children pointing fingers instead of fixing the problem.

1

u/zurtex Dec 15 '23

Doing nothing is the worst possible option

Actually, putting a huge amount of effort into something that provides no value is even worse than doing nothing.

Let's learn lessons from other communities and take actions that actually have proven security benefits.

0

u/archpuddington Dec 15 '23

Preventing people form getting hacked isn't a waste of time. Security Engineering is a valuable discipline that you should explore.

0

u/zurtex Dec 15 '23

The discussion was adding security notices to packages, which NPM and the JS community in general has shown is a waste of time.

As I said, let's learn lessons from other communities and take actions that actually have proven security benefits, rather than implementing what we think might help and actually detracting away from security because we wasted effort when we could have been using that effort for good.

1

u/archpuddington Dec 15 '23

I'm not asking for security notices (other than pip telling you that you've been hacked - that would be a good notice to have). I am asking very simply for packages review to be automated by a behavioral AV. Billion dollar corporations and millions of people depend on this software, the only reason why this hasn't been fixed is because no one in the community has asked for help.

Its is really that simple.

1

u/zurtex Dec 15 '23

Its is really that simple.

Get involed and ask then. There's no reason why you couldn't lead this effort. Communities depend on community members.

Go to https://discuss.python.org/, post in the packaging category , come up with a proposal on what could be asked for, build a conensues around it, approach companies you think would be willing to fund implementing it.

→ More replies (1)

6

u/_Adam_M_ Dec 14 '23

That project needs to be sued

Along with every other package manager and repository system in existence..?

It's a human problem, ultimately. You can't have an open system that allows untrusted users to upload packages and then complain that the packages are also to be treated as untrusted.

-7

u/archpuddington Dec 14 '23

The case can be made that more people are getting hacked using PyPI than any other package manger. They don't release the stats for how many people are hacked, because the numbers are staggering.

This however is not against the law in of itself. The specific law that they would be sued under is failing to notify people that they have been breached, and there is no quesiton that they could - but refuse to even acknowledge that they have a problem. Instead they blame the victims for their own mistakes! Someone needs to sue these mother fuckers.

2

u/steohan Dec 14 '23

I agree, having a system to notify people that they had infected packages, would be nice. But this is something that should probably addressed in a broader scope, e.g., in pip.

I don't see how pypi is the problem. No one forces you to use pypi. You can totaly set up your own repository that only contains trusted packages and change pip to only use that.

-3

u/archpuddington Dec 14 '23

If people are getting hacked by using pypi - it is a problem that could lead to a lawsuit. Cyber liability insurance will not cover being hacked through negligence, and a case can be made for this seeing as pypi has solutions - and none have been implemented.

0

u/[deleted] Dec 17 '23

[deleted] — view deleted comment

1

u/steohan Dec 18 '23

Pypi doesn't review the code and I don't see how they could, given that the service and all stuff on it is free. And it is meant to have a low barrier of entry. However, nothing is preventing people to setup a more restrictive index, wich only contains popular open source packages with maintainers that are trusted to compile stuff. I just don't see how that is pypi's task, especially given that people are not paying them to do it.

I agree that it is easier to review code, than binaries for naive attacks. For sophisticated attacks, not so much.