FortiGuard Labs Threat Research
Our team has discovered another 0-day attack embedded in a PyPI package (Python Package Index). This one is called “aioconsol.” It was found on December 9, 2022, by monitoring an open-source ecosystem. This Python package was published on December 6, 2022, as shown in its official PyPI repository. As can be seen, all three versions of this malware were published on the same day. Like the “shaderz” zero-day PyPI attack we discovered and posted last week, this malicious package does not include a clear description of its project or source page.
Version 2.0 of the package includes malicious code in its setup.py installation script that writes what appears to be a binary to a file called “test.exe” and executes it as a part of its installation.
In the previous versions, 1.0 and 0.0, a similar malicious code appears in its __init__.py scripts, as shown below.
As shown in the VirusTotal entry below, several vendors flag this binary exe as malicious (SHA 256):
Let’s jump right into the binary exe and run it. It creates a subprocess called ‘stub.exe.’
It drops a series of files to the folder ‘%USER%\AppData\Local\Temp\onefile_%PID_%TIME%’, as shown below.
This dropped executable ‘stub.exe’ is flagged as malicious by only a handful of vendors (SHA 256):
After we run test.exe, we see that it copies itself to ‘%USER%\AppData\Local\WindowsControl’ as ‘Control.exe’ and drops a ‘run.bat’ batch file.
The run.bat script shows the path to the file ‘Control.exe,’ which may be used to run it at startup.
This is the second malicious zero-day Python Package Index (PyPI) supply chain attack we have discovered in less than a week. This technique is often used because malware authors can store an entire binary executable inside a simple python script. This can have drastic effects, potentially damaging your system and exposing users to vulnerabilities. Individuals and organizations need to be wary of installing python packages in the wild as they may include malware.
FortiGuard AntiVirus detects the malicious executables identified in this report as
The FortiGuard AntiVirus service is supported by FortiGate, FortiMail, FortiClient, and FortiEDR. Customers running current AntiVirus updates are protected.
The FortiGuard Web Filtering Service detects the download URLs cited in this report as Malicious and blocks them.
FortiGuard Labs responsibly disclosed the malicious aioconsol package to Python and it has been removed.