The Python package repository PyPI (Python Package Index) has temporarily banned new user registrations and the creation of new projects due to a continuous massive upload of malicious packages during an automated attack. The block was implemented after 566 packages containing malicious code, disguised as 16 popular Python libraries, were uploaded to the repository on March 26 and 27.
Package names were formed using typoscoping, i.e., assigning similar names differing by individual characters, such as temsorflow instead of tensorflow, requyests instead of requests, asyincio instead of asyncio, etc. In conducting such attacks, attackers rely on inattentive users who make typos or do not notice the differences in names when searching or clicking on links from forums and chats where attackers leave deceptive instructions.
Malicious packages are based on the code of legitimate libraries, which incorporate specific modifications that install malware on the system to search for and send confidential data and files containing passwords, access keys, cryptocurrency wallets, tokens, and session cookies. The malicious code is embedded in the setup.py file, which runs during the package installation. During activation, the modification downloads the main malicious components from external sources. server.
In two days, attackers uploaded 29 malicious variants of the tensorflow package, 26 of BeautifulSoup, 26 of PyGame, 15 of SimpleJson, 38 of Matplotlib, 26 of PyTorch, 67 of CustomTKInter, 28 of selenium, 17 of playwright, 15 of asyncio, and 67 of requirements. Additionally, isolated cases of counterfeit libraries requests, py-cord, colorama, capmonstercloudclient, pillow, and bip-utils were identified.
A separate attack on the Top.gg community, which has 170,000 users, is noteworthy. During the attack, the perpetrator compromised the GitHub account of one of the developers of top.gg by stealing browser cookies. The attacker also added three packages to the PyPI repository and registered domains pypihosted.org and pythanhosted.org, which were set up as mirrors to distribute the malicious dependencies for the packages.
A modification was made through a compromised GitHub account in the top.gg project repository, which contained the Python wrapper over the Top.gg API. The change added a requirements.txt file that listed downloadable dependencies, including a link to a malicious clone of the 'colorama' package hosted on a fraudulent domain, pypihosted.org, disguised to resemble the legitimate pythonhosted.org domain, from which packages are usually downloaded from PyPI.
Source: opennet.ru
