Site icon Secplicity – Security Simplified

Python Modules: Not As Safe As You Think

 

We normally think of malware and threats coming from executables, packages, and scripts. Researchers recently found a supply chain attack using a different method.

Programs use Python scripts to manage and run services. You especially see this in Unix-based operating systems. When it comes to security many professionals use Python to automate tasks. Because of the prevalence of Python, especially in IT and IT security, any successful supply chain attack on Python would create disastrous consequences. The problem comes when programmers assume the downloaded module can’t infect their device outside of the local scripting environment. As you will learn, this isn’t true.

Researchers at Sonatype recently found multiple modules that programmers can add to their Python scripts that contain the cryptominer Ubqminer. Sonatype found, multiple modules use a form of typosquatting to make the name of their malicious module look similar to the legitimate module, “matplotlib.” An unsuspecting user may download the fake module and install it. The module then downloads the aforementioned cryptominer and runs it in the background. Like most malicious cryptominers, users would experience a slowdown on their computer while mining cryptocurrency for the script’s author.

Attackers have seen some success exploiting this type of attack using JavaScript modules, but we have yet to see it spread into Python programing as much. When running any Python script or module, treat it as unknown software until you review the script. Only trust well-known modules and ensure you download the right one (watch out for purposely obscured misspellings). If you must use an unknown module be sure you run it in a virtual environment to test the results.

Exit mobile version