Shai-Hulud Attack Uses 19 PyPI Packages to Steal Developer Secrets

· Original article ↗

Summary

Socket researchers say 37 malicious releases across 19 PyPI packages used Python startup hooks and a JavaScript payload to steal developer secrets, with persistence and evasion mechanisms also observed.

Key points

  • Socket identified 37 malicious releases across 19 PyPI packages, including bioinformatics tools such as Dynamo, Spateo, and CoolBox.
  • A malicious .pth startup hook could trigger when Python starts and download the Bun JavaScript runtime to run an obfuscated _index.js payload.
  • The malware targeted developer secrets including GitHub tokens, cloud credentials, SSH keys, package-publishing tokens, and CI/CD data.
  • Secrets were exfiltrated through automatically created GitHub repositories; Socket also identified a direct HTTPS method pointing to api[.]anthropic[.]com/v1/api.
  • The malware checked for Russian locales and security tools, and established persistence through Linux systemd services and macOS LaunchAgents.
  • Socket recommends rotating exposed secrets and restoring affected environments from safe backups; defenders can hunt for unexpected Bun downloads and Python-to-Bun execution chains.

Article Details

Attack Vectors
  • Compromised PyPI package releases included executable .pth startup hooks that triggered an obfuscated _index.js payload when Python started.
  • The payload attempted to download the Bun JavaScript runtime from GitHub and used it to execute the bundled script.
  • The malware collected developer secrets and exfiltrated them through automatically created GitHub repositories and a separate direct HTTPS method.
Defensive Notes
  • Rotate secrets exposed on systems that installed affected packages and restore those environments from safe backups.
  • Inspect Python packages for executable .pth startup hooks and investigate unexpected downloads of the Bun runtime from GitHub.
  • Hunt for process chains in which Python launches Bun to execute _index.js.

MITRE ATT&CK

T1027 · Obfuscated Files or InformationThe bundled JavaScript payload, named _index.js, was obfuscated.T1059.006 · PythonA malicious .pth startup hook ran when Python started and triggered the payload execution chain.T1059.007 · JavaScriptThe malware used an obfuscated JavaScript payload named _index.js, executed with the Bun JavaScript runtime.T1105 · Ingress Tool TransferThe .pth hook attempted to download the Bun JavaScript runtime from GitHub.T1195.002 · Compromise Software Supply ChainThe attack compromised 19 PyPI packages and distributed malicious releases through the software supply chain.T1497.001 · System ChecksThe malware checked for Russian locales or environments as an evasion measure.T1518.001 · Security Software DiscoveryThe malware checked for security tools, including StepSecurity Harden-Runner.T1528 · Steal Application Access TokenThe malware targeted GitHub tokens and publishing tokens as part of its collection of developer secrets.T1543.001 · Launch AgentThe malware established persistence through LaunchAgents on macOS.T1543.002 · Systemd ServiceThe malware established persistence through systemd services on Linux.T1552.001 · Credentials In FilesThe payload collected developer secrets from files and configurations, including .env, .npmrc, and .pypirc files.T1552.004 · Private KeysSSH keys were among the developer secrets the malware targeted.T1567.001 · Exfiltration to Code RepositoryThe malware exfiltrated secrets through automatically created GitHub repositories, using GitHub Actions.

Malware

Products

Tools

Industries

Related Articles