New Shai-Hulud attack trojanizes 19 science-focused PyPI packages
A new supply-chain attack, dubbed Shai-Hulud, has compromised 19 popular Python packages hosted on the PyPI, distributing a trojan designed to steal developer secrets. The malware leverages a chain of execution to download and run a malicious JavaScript payload, targeting a wide range of credentials and configuration files. This attack highlights the risks associated with compromised dependencies and the need for robust security practices within software development workflows.
The attack, discovered by Socket, involved the malicious release of 37 artifacts across 19 packages, all seemingly maintained by a single individual. The core of the malware utilizes a ‘*-setup.pth’ file and an obfuscated JavaScript payload (‘_index.js’) to execute a malicious script. Users simply starting Python would trigger the execution, leading to the download and execution of the Bun JavaScript runtime. This method allows for a delayed execution trigger, potentially compromising any Python-based tool or process that utilizes the affected packages.
The compromised packages, many of which are bioinformatics tools, targeted a vast array of developer secrets, including GitHub tokens, npm and PyPI credentials, cloud provider credentials (AWS, GCP, Azure), SSH keys, and CI/CD secrets. The attackers utilized GitHub Actions to host stolen secrets and employed direct HTTPS connections to a disguised Anthropic API endpoint for exfiltration. The malware incorporates evasion techniques, such as checking for Russian locales, and establishes persistence through systemd services and LaunchAgents. Socket recommends immediate action for organizations that used the affected packages, including rotating secrets and restoring environments from backups.