
Microsoft's 'agent-framework' package compromised on PyPI and steals cloud credentials
Versions 1.26.1 and 1.26.2 of the agent‑framework package were released with code that collects Azure credentials and tokens on every Python startup.
Malicious versions 1.26.1 and 1.26.2 of the agent‑framework package were published on PyPI and contain code that collects credentials and identity tokens in Python environments.
According to reports from Aikido, Endor Labs, OX Security, SafeDep, Socket, StepSecurity, and Wiz, the packages were inserted into Microsoft's official repository on November 17, 2026, and when installed, they create .pth files that execute credential theft on every Python interpreter startup.
The agent‑framework is an open-source meta-package maintained by Microsoft that enables the construction and orchestration of AI agents in Python. The official package, prior to version 1.26.0, was widely adopted by developers building CI/CD pipelines and AI experimentation environments.
.pth File Injection and Automatic Execution
In versions 1.26.1 and 1.26.2, the malicious authors added .pth files to the site‑packages directory. The file agent_framework_meta.pth (version 1.26.1) and af_runtime_diag.pth (version 1.26.2) contain import statements that are processed by the Python interpreter on each startup, regardless of whether the package is explicitly imported. This technique allows the theft code to run even during the execution of tools such as pip or build scripts.
Types of Data Collected
The payload captures environment variables that match credential patterns, configuration files such as ~/.azure/*.json, .npmrc, pip.conf, .netrc, .git‑credentials, .docker/config.json, OIDC tokens from GitHub Actions, Azure managed identity tokens, Azure instance metadata (IMDS), and even .env files or JSON containing secrets. In total, up to 8,000 response characters are stored in a JSON document.
After collection, the document is compressed with zlib, encoded in Base64, and sent via an HTTPS POST request to a webhook endpoint controlled by the attackers.
Impact and Recommendations
The package logged about 190,000 downloads per month, indicating widespread potential exposure. Microsoft has not yet disclosed details on how the publishing access was compromised. While the malicious versions remain removed from PyPI, it is recommended to isolate affected hosts, pin the dependency to version 1.26.0 or earlier, review proxy and DNS logs for webhook calls, rotate exposed credentials, audit Azure identities and GitHub Actions workflows, and monitor unexpected changes in site‑packages directories.
CyberX Technical Analysis
The attack exploits Python's .pth file functionality, which allows automatic code execution upon interpreter startup. This attack surface is known but rarely seen in packages distributed via PyPI, making it particularly dangerous in CI/CD environments where the interpreter can be started many times.
Versions 1.26.1 and 1.26.2 introduce two different files: agent_framework_meta.pth which imports an internal module responsible for initiating the theft, and af_runtime_diag.pth which, in addition to the previous behavior, adds a af_runtime_diag.py module capable of collecting OIDC tokens from GitHub Actions. Both depend on read privileges in the package installation directory, which is normally accessible to any user who can install Python packages.
The collected code includes static credentials (configuration files) and dynamic credentials (managed identity tokens and OIDC). The ability to request new tokens from Azure's managed identity expands the impact, allowing the attacker to obtain credentials with read or write scope on cloud resources.
From a mitigation standpoint, the immediate removal of the compromised versions from PyPI eliminates the possibility of new downloads, but does not prevent already compromised environments from continuing to run malicious code until the .pth file is removed. It is recommended to inspect site‑packages directories on build servers, containers, and development machines, as well as to apply package signing policies (e.g., PEP 458/PEP 480) to validate the integrity of uploads to PyPI.
As a long‑term preventive measure, organizations should restrict the installation of packages from external sources to trusted internal repositories, enable package hash verification (via pip hash), and monitor the creation of .pth files on critical systems.
CyberX SOC Intelligence Bulletin
The agent‑framework 1.26.1/1.26.2 package introduced .pth files that execute malicious code on every Python interpreter startup, collecting local credentials and Azure identity tokens, and sending them to a webhook controlled by the attackers.
Indicators of Compromise (IoCs)
No file hashes or specific domains were disclosed beyond the webhook endpoint (webhook.site) mentioned in the reports. It is recommended to monitor the creation of .pth files in site‑packages and HTTPS traffic to unknown webhook domains.
Recommended Mitigations
- Immediately remove the
agent_framework_meta.pthandaf_runtime_diag.pthfiles from all Python environments. - Reinstall the package at version 1.26.0 or earlier from a trusted internal repository.
- Audit proxy/DNS logs for requests to the domain
webhook.sitebetween 08:35 UTC and 09:20 UTC on November 17, 2026. - Rotate Azure credentials, OIDC tokens, and secrets stored in configuration files.
- Apply package signing policies and restrict installations to internal repositories.
Investigation Notes
At this time, there is no public evidence that the PyPI publishing access was obtained through compromise of Microsoft account credentials; the source of the compromise remains unknown. Further investigations should focus on package publishing logs and the build supply chain that used the agent‑framework.
Frequently Asked Questions
What versions of agent-framework were compromised?
Versions 1.26.1 and 1.26.2 of the agent-framework package were compromised and contained malicious code.
How does the malicious code execute?
The package creates .pth files in the site-packages directory that contain import statements processed by the Python interpreter on each startup.
What information does the malware steal?
The payload captures environment variables matching credential patterns, configuration files like Azure JSON and .netrc, OIDC tokens from GitHub Actions, and Azure managed identity tokens.
How is the stolen data exfiltrated?
The collected data is compressed with zlib, encoded in Base64, and sent via an HTTPS POST request to a webhook controlled by the attackers.


