Browse / Unsafe Model Loading and Supply Chain / AML.CS0015
Compromised PyTorch Dependency Chain
- Technique
- Supply Chain Compromise: Software
- Target
- PyTorch (Incident)
How it worked
- Initial Access · Supply Chain Compromise: Software
A malicious dependency package named
torchtritonwas uploaded to the PyPI code repository with the same package name as a package shipped with the PyTorch-nightly build. This malicious package contained additional code that uploads sensitive data from the machine.
The malicioustorchtritonpackage was installed instead of the legitimate one because PyPI is prioritized over other sources. See more details at this GitHub issue. - Collection · Data from Local System
The malicious package surveys the affected system for basic fingerprinting info (such as IP address, username, and current working directory), and steals further sensitive data, including:
- nameservers from/etc/resolv.conf
- hostname fromgethostname()
- current username fromgetlogin()
- current working directory name fromgetcwd()
- environment variables
-/etc/hosts
-/etc/passwd
- the first 1000 files in the user's$HOMEdirectory
-$HOME/.gitconfig
-$HOME/.ssh/*. - Exfiltration · Exfiltration via Cyber Means
All gathered information, including file contents, is uploaded via encrypted DNS queries to the domain
*[dot]h4ck[dot]cfd, using the DNS serverwheezy[dot]io.
Summary
Linux packages for PyTorch's pre-release version, called Pytorch-nightly, were compromised from December 25 to 30, 2022 by a malicious binary uploaded to the Python Package Index (PyPI) code repository. The malicious binary had the same name as a PyTorch dependency and the PyPI package manager (pip) installed this malicious package instead of the legitimate one.
This supply chain attack, also known as "dependency confusion," exposed sensitive information of Linux machines with the affected pip-installed versions of PyTorch-nightly. On December 30, 2022, PyTorch announced the incident and initial steps towards mitigation, including the rename and removal of torchtriton dependencies.
References
- https://pytorch.org/blog/compromised-nightly-dependency/
- https://www.bleepingcomputer.com/news/security/pytorch-discloses-malicious-dependency-chain-compromise-over-holidays/
Source: MITRE ATLAS case studies, used under Apache 2.0.