Description

Six malicious packages were discovered on PyPI, the Python Package Index, while using the Cloudflare Tunnel to avoid firewall limitations for remote access. These packages deployed information-stealing and RAT (remote access trojan) malware with the goal of collecting sensitive user information saved in browsers, performing shell commands, and stealing written secrets using keyloggers. Cloudflare Tunnel enables clients, including those with free accounts, to create a bidirectional tunnel from a server to the Cloudflare infrastructure, allowing web servers to become publicly accessible via Cloudflare without the need to configure firewalls, open ports, or deal with other routing issues. Even if the device is protected by a firewall, the threat actors use this tunnel to remotely access a remote access trojan operating on the infected device as the 'Flask' script (cftunnel.py). This script has the ability to exfiltrate particular files and directories, run shell commands on the compromised machine, run Python code, steal the victim's username and IP address, and download and launch additional payloads. Additionally, it allows a one-frame-per-second "live" remote desktop broadcast that starts up when the victim enters something or moves their mouse. To evade discovery by developers, the installer (setup.py) on these files contains a base64-encoded string that decodes to a PowerShell script that sets the '-ErrorAction SilentlyContinue' flag so that the script will silently continue even if it encounters failures. The PowerShell script will then download a ZIP file from a distant resource, unpack it in a temporary directory on the local machine, and instal a number of dependencies and extra Python packages that enable remote control and screenshot capture. During that stage, two more packages, 'flask' and 'flask cloudflared,' are discreetly installed. "server.pyw," one of the ZIP files, starts four threads: one to establish persistence between system reboots, one to ping a proxied onion site, one to start a keyboard logger, and one to steal data from the compromised machine.