Live data from Hacker News

Dozens of malicious PyPI packages discovered targeting developers

blog.phylum.io

51–60 of 334 posts

Re: Dozens of malicious PyPI packages discovered targeting developers

#51
post #33

can there be a "blue checkmark" system for pypi authors? I'm sure that's been brought up and rejected for reasons .

It's not going to be a "blue checkmark" per se, but we're currently working on integrating Sigstore signatures into PyPI. The idea there will be that you'll be able to verify that a package's distributions are signed with an identity that you trust (for example, your public email address, GitHub repository name, or GitHub handle).

Re: Dozens of malicious PyPI packages discovered targeting developers

#52

These sorts of things is why D doesn't allow any system calls when running code at compile time, and such code also needs to be pure. Of course, this doesn't protect against compiling malicious code, and then running the code. But at least I try to shut off all attempts at simply compiling the code being a vector.

I'm honestly not sure the benefits of executing code during compilation/install outweigh the bad. Most attacks we have seen leverage this as the attack vector.

The problem comes when you need to do something bespoke and custom, like building a C dependency so you can link it into your Python (or whatever language) library. Sometimes your options are "run a makefile" or "reimplement an entire library from scratch". I'm not saying that this isn't a problem; it is. I think the better solution is transparent sandboxing for dev environments.

Re: Dozens of malicious PyPI packages discovered targeting developers

#53

Earlier quoted context omitted.

Yes, this works really well. But as soon as you deploy it, the actors change tactics. We've had to build a defense in depth approach to discovering malicious packages as they are introduced into the system.

it is probably very easy to bypass, by creating a sub package that can do the decoding via proxy functions, which is not evil at all, and depending on that package on the evil one. It won’t trigger the alarm, as it is indirectly depending on the base64 :)

Exactly, I don't think you can rely on a naïve import to determine maliciousness. We've basically had to build out heuristics that are capable of walking function calls for this exact reason. Otherwise things are just too noisy.

Re: Dozens of malicious PyPI packages discovered targeting developers

#54
post #52

Earlier quoted context omitted.

I'm honestly not sure the benefits of executing code during compilation/install outweigh the bad. Most attacks we have seen leverage this as the attack vector.

The problem comes when you need to do something bespoke and custom, like building a C dependency so you can link it into your Python (or whatever language) library. Sometimes your options are "run a makefile" or "reimplement an entire library from scratch". I'm not saying that this isn't a problem; it is. I think the better solution is transparent sandboxing for dev environments.

> I think the better solution is transparent sandboxing for dev environments.

I don't disagree at all. We're building an open source sandbox for devs right now for this exact reason. Linked it in another comment.

Re: Dozens of malicious PyPI packages discovered targeting developers

#55
post #50

In a previous HN discussion on the topic of rogue Python packages, readers had suggested bubblewrap and firejail for sandboxing. They limit the access a script and its packages have to your filesystem and network. I think that's the better approach - just assume all packages are malicious by default. Can't rely on scanners because of the large number of packages and attacks.

Quoted post unavailable.

It's a problem with every open ecosystem where libraries can be downloaded and run. Rust, Golang, Node all have the same problem. That's why I think it's better to assume anything we download is malicious. Stuff like Bubblewrap and Qubes OS seem to be the better approach compared to relying on vulnerability hunters and scanning tools.

Re: Dozens of malicious PyPI packages discovered targeting developers

#56

I started to develop only inside VMs, with a full Desktop, IDE, browser etc. inside the virtual machine. There have been to many contaminations of major package repos lately. Only one typo in an import statement up the dependency chain and you’d be compromised.

This is a good approach, though presumably the VM still has access to your Github credentials (via the browser) and your SSH keys? It'll limit the fallout of getting owned to anything reachable from Github (is it against Github's TOS to have multiple accounts?), less if you have 2FA (does there exist 2FA for SSH keys (I don't mean passphrases)?), but I think it would be better for just my build/run/test cycles to be cordoned off into their own universe, with a way for just the source code itself to cross the boundary.

Re: Dozens of malicious PyPI packages discovered targeting developers

#57
post #7

It's using base64 encoded strings to deliver the initial stage. Can this be avoided/flagged more easily if by adding a scan of statements featuring base64 or import?

We tried doing this on PyPI a couple of years ago, and it produced a large number of false positives (too many to manually review).

You can see the rules we tried here[1].

[1]: https://github.com/pypi/warehouse/blob/main/warehouse/malwar...

Re: Dozens of malicious PyPI packages discovered targeting developers

#58
post #15
post #13

Earlier quoted context omitted.

Python is just far more popular. RubyGem: https://www.bleepingcomputer.com/news/security/malicious-rub... Perl CPAN https://news.perlfoundation.org/post/malicious-code-found-in...

I think this has more to due with the contexts/industries we typically see Python used in over pure popularity. If popularity was the only factor I'd expect to seeing a lot more news about these problems in Java/PHP ecosystems which are absolutely massive.

I mean, PHP is pretty much a domain specific language, and we're only about a year out from log4j.

Re: Dozens of malicious PyPI packages discovered targeting developers

#59

The guy who runs the C2 openly has the source code for the stealer on his GitHub. Why doesn't GitHub do anything about this shit? I've personally been hacked by a supply chain attack via a GitHub wiki link. I contacted GitHub support and didn't hear back from them for 3 months. They are completely useless.

No post body was provided.

Re: Dozens of malicious PyPI packages discovered targeting developers

#60
post #21

The article doesn't explain what exactly the "W4SP Stealer" does. Would someone be able to explain?

It downloads a script that, at least right now, will turn around and grab cookies and passwords from browsers and send the data off to an discord webhook.

> discord webhook

Hah. Is this true? I find it funny since IRC has/had this reputation for being a means of communication with malware and it's often blocked on this grounds.

Nice to know that malware is going on with the times and is using Discord for that now.

Post reply on HN