Security

Fake Python libraries removed from PyPi when caught stealing SSH and GPG keys, reports ZDNet

3 min read

Yesterday, ZDNet reported that the Python security team removed two fake Python libraries from PyPI (Python Package Index). These libraries were caught stealing SSH and GPG keys from the Python projects.

As per ZDNet, the two malicious clones were discovered by a German software developer Lukas Martini on 1st Dec. Both libraries were removed on the same day after Martini notified the developers and the PyPI security team.

The two libraries were created by the same developer and mimicked as other more popular libraries — using a technique called typosquatting, to register similar-looking names. The first is “python3-dateutil,” which imitated the popular “dateutil” library. The second is “jeIlyfish” (here the first L is an I), which mimicked the “jellyfish” library. One of them was uploaded on Pypi two days before while the other one was live for more than a year.

Purpose of stealing SSH and GPG keys

According to Martini, the malicious code was present only in the jeIlyfish library. The python3-dateutil package didn’t contain malicious code of its own, but it did import the jeIlyfish library, meaning it was malicious by association.

The malicious code read a list of hashes stored in a GitLab repository. The nature and purpose of these hashes is unknown, as neither Martini or the PyPI team detailed the behavior of stealing the keys before the library was removed.

ZDNet spoke to Paul Ganssle from the dateutil dev team, “The code directly in the `jeIlyfish` library downloads a file called ‘hashsum’ that looks like nonsense from a gitlab repo, then decodes that into a Python file and executes it,” Ganssle states.

It looks like [this file] tries to exfiltrate SSH and GPG keys from a user’s computer and sends them to this IP address: http://68.183.212.246:32258. It also lists a bunch of directories, home directory, PyCharm Projects directory,” Ganssle added. “If I had to guess what the purpose of that is, I would say it’s to figure out what projects the credentials work for so that the attacker can compromise that person’s projects.

Python developers advised to review projects

Excluding the malicious code, both typosquatted packages were identical copies of the original libraries, meaning they would have worked as the originals. Developers who didn’t pay attention to the libraries they downloaded or imported into their projects are advised to check if they’ve used the correct package names and did not accidentally use the typosquatted versions.

If they accidentally used any of the two, developers must change all SSH and GPG keys which they’ve used over the past year. This is the third time the PyPI team intervenes to remove typo-squatted malicious Python libraries from the official repository. Similar incidents took place recently in July 2019 and another in October 2018 and September 2017.

On this news, developers on Hacker News discuss about this as an OS issue. One of the user comments, “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 programs running under the terminal inherit the permissions.

Microsoft has started adding short life VMs. No idea if that’s good. Both MS and Apple offer their App stores with more locked down experiences though I’m sad they conflate app security and app markets.

Basically anytime I run any software, everytime I run “make” or “npm install” or “pip install” or download a game on Steam etc I’m having to trust 1000s of strangers they aren’t downloading my keys, my photos, my docs, etc…I think you should be in control of your machine but IMO it’s time to default to locked down instead of defaulting to open.”

Read Next

Introducing Spleeter, Tensorflow based python library that extracts voice and sound from any music track

SatPy 0.10.0, python library for manipulating meteorological remote sensing data, released

Meet Pypeline, simple python library for building concurrent data pipelines

Fatema Patrawala

Being a Senior Content Marketing Editor at Packt Publishing, I handle vast array of content in the tech space ranging from Data science, Web development, Programming, Cloud & Networking, IoT, Security and Game development. With prior experience and understanding of Marketing I aspire to grow leaps and bounds in the Content & Digital Marketing field. On the personal front I am an ambivert and love to read inspiring articles and books on life and in general.

Share
Published by
Fatema Patrawala

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago