Live data from Hacker News

Two malicious Python libraries caught stealing SSH and GPG keys

zdnet.com

41–50 of 323 posts

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#41

"pip" has a usability problem. It should do a lot more at preventing this kind of thing. When using pip, it's not easy to tell information like the release date, how many versions have been released, and so on. Since such info is available from PyPI API, I wrote my own "pypisearch" script to sort by latest release date and include number of releases to weed out packages that seem useful but are old or rarely released…

Is the code public? I'd love to use something like that.

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#42
post #6
post #4

> The first is "python3-dateutil," which imitated the popular "dateutil" library. The second is "jeIlyfish" (the first L is an I), which mimicked the "jellyfish" library.

Wish they listed out how many installs.

No info on installs but some more details on each:

https://libraries.io/pypi/jeIlyfish

https://libraries.io/pypi/python3-dateutil

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#43
post #39

Maybe ash keys and got keys need to be protected from access by anything local unless given permission? Right now they are just files sitting there that can be read by any standard user process right?

Ok macOS you can easily throw your SSH keys into the secure Keychain (not that I do this...).

It should be the default that they are protected though on all os. We should not automatically trust locally installed apps anymore. They should be sandboxed by default like on Android and they should ask for permissions as they need them.

Windows and Linux need to get with the times.

My dev env should be sandboxed like everything else. Git can have ssh permissions but not every random tool from pip or the ceasepool that is npm.

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#44
This is part of why I install my Python dependencies from downstream Linux distro repos. I never use virtualenv. If a distro is missing a package I need, it's a simple process to put it together, and the additional steps and checks built into the process stop close to 100% of these issues. Getting a human here also lets you do things like patch out telemetry or other anti-features.

Software repositories without a human review process are a bloody stupid idea.

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#45
post #7

There are probably several open-source projects that you can download today that include unknown malicious code. But they will be discovered eventually. Proprietary software, on the other hand, can keep malicious code during their entire life of relevancy. And in fact, it's rare for proprietary software to not have malicious code these days, with personal data being sent to servers, ads being delivered, and installer…

Complete false equivalency. Exploiting user data deliberately, when you technically mention it in a thousand page legal document, is completely different from distributing malware because your dev machines got infected.

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#46
post #24

I don't know what the solution is but it feels like this is a much bigger issue and we need some rethinking of how OSes work by default. Apple has taken some steps it seems the last 2 MacOS updates where they block access to certain folders for lots of executables until the user specifically gives that permission. Unfortunately for things like python the permission is granted to the Terminal app so once given, all pr…

This is literally what SELinux does, and has been able to do for years. We don't need "default block lists" - we need solid SELinux policy in all distros.

There's a fair amount of other solutions to this too.

Things today:

- Protective monitoring. If it's stealing your key, it's presumably sending it somewhere, so somebody alerting should be going off asking clients are calling something external.

- Peer review. Maybe its about time we question whether we should actually be running so many random modules without actually vendoring and reading the code.

- Subscribing to security lists, so the people who actually do the above stop you from using dirty modules.

- Yubikeys, etc.

Things in the future:

- New home directory model. I believe systemd crew are looking into this, so I imagine it'll be hated, even if it does help solve similar issues.

- Newer distro models such as fedora silverblue where every process is isolated. I believe this currently mounts your home directory though, so maybe wouldn't work.

- New FS layout. Putting .ssh keys in something like .secret/ssh would likely make it easier to not mount secrets into isolated processes and help MACs too.

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#47
In the end I think the solution to these issues will be something like what's promised by the Bytecode Alliance[0]. The idea is you give each package its own WASM sandbox with granular control over its permissions.

That solution also has the benefit of allowing you to call a package from any language from your language of choice.

I highly recommnend reading their the article introducing the idea, its very convincing:

[0] https://bytecodealliance.org/articles/announcing-the-bytecod...

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#48
post #9

What's the best information source for me to follow to keep up to date on these kinds of library vulnerabilities? I would make a feed of the homepages for all the libraries I know I use, but that won't help me with the libraries I use without knowing.

"bandit" (available in pypi) is a nice static analysis tool - I don't remember if it is able to recurse into dependencies though

[safety](https://pyup.io/safety/) is a commercial product that monitors your dependencies for this kind of shenanigans

LGTM.com seemed to be working in this area - Semmle was acquired by github/microsoft

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#49

"pip" has a usability problem. It should do a lot more at preventing this kind of thing. When using pip, it's not easy to tell information like the release date, how many versions have been released, and so on. Since such info is available from PyPI API, I wrote my own "pypisearch" script to sort by latest release date and include number of releases to weed out packages that seem useful but are old or rarely released…

Is the code public? I'd love to use something like that.

It isn't. I'll make it public and announce it here by Friday.

Re: Two malicious Python libraries caught stealing SSH and GPG keys

#50
post #12

Anyone here not encrypting their private keys? Also known_hosts file is a double edged sword. It's pretty sensitive in combination with a private key.

Modern SSH versions only store hashes of domain names in the known_hosts file exactly for this reason.
Post reply on HN