Microsoft's Python agent framework hijacked to steal cloud credentials
Two malicious versions of Microsoft's agent-framework on PyPI stole credentials and requested fresh cloud tokens before being quarantined on 17 November.
Photo: The RegisterKey points
Attackers published two malicious versions of Microsoft's agent-framework on PyPI that stole credentials and requested fresh cloud tokens before being quarantined.
Attackers hijacked Microsoft's official agent-framework package on PyPI and used it to distribute credential-stealing malware, multiple security research firms reported on 18 November. Two malicious versions, 1.26.1 and 1.26.2, appeared on 17 November and stayed live for less than an hour, according to OX Security and Aikido Security. The package, which has about 192,534 monthly downloads, is used to build and deploy AI agents.
The malware harvested environment variables, credential files, and secrets from Azure, GitHub, Docker, Hugging Face, OpenAI, and other services. It also requested fresh identity tokens from GitHub Actions, Azure DevOps, and Azure itself, which were exfiltrated to the same webhook.site address. "That combination of passive theft and active token requests makes it especially dangerous in cloud build environments, because even short-lived tokens are useful when they're exfiltrated right away," said researchers at OpenSourceMalware.
How the malware worked
The payload ran automatically every time Python started, even if no code imported the package, OX Security said. The malicious versions also installed the genuine 1.26.0 framework code, so applications kept working and the compromise was easy to miss. The malware was disguised as diagnostics, sitting in a module named _telemetry.py and sending data with a user agent labeled "af-runtime-diagnostics," OX said.
The stealer collected environment variables with names containing words such as TOKEN, SECRET, PASSWORD, KEY, AZURE, AWS, GITHUB, and OPENAI, OX said. It also read up to 60 credential files, including Azure CLI settings, Git and Docker credentials, npm and pip configuration, Hugging Face tokens, Azure DevOps build agent credentials, and application .env files. It pulled secrets from up to 300 other running processes as well.
The malware also asked for new tokens. Inside Azure DevOps pipelines, it requested an identity token that can be exchanged for Azure access, OX said. It also requested managed identity tokens for Azure services, including Resource Manager, Microsoft Graph, Key Vault, Storage, Cognitive Services, AI Foundry, and Azure DevOps. Endor Labs said the attack was aimed mainly at automated build systems: "Developer laptops are in scope, but the payload is written for CI runners and Azure workloads."
The attack timeline
PyPI quarantined the first malicious release, but the attacker published a second version roughly 2.5 minutes later, which was also quarantined about eight minutes afterward. The second release indicates that the attacker still had publishing access after the initial quarantine. The first version went up at 20:35 UTC and the second at 21:08 UTC, according to Aikido Security. Both were gone by about 21:20 UTC.
Version 1.26.1 used agent_framework_meta.pth to execute the credential stealer in agent_framework_meta/_telemetry.py during Python startup, according to Socket and StepSecurity. The second release restored the original package initializer and moved the malicious code into af_runtime_diag.pth and af_runtime_diag.py. Both versions exfiltrated collected data to the same attacker-controlled endpoint, https://webhook[.]site/d381fd80-ec62-42ad-8f5c-d1b15103c9bb. It remains unclear how the attacker gained access to publish malicious releases under Microsoft's official PyPI project. Microsoft has not said publicly how the attacker got access, and the company did not immediately respond to a request for comment. The agent-framework GitHub repo is offline as of writing, and Microsoft's repo for ONNX Runtime is also offline, though neither Microsoft nor security researchers have linked the ONNX repo's pull to the malware campaign.
What developers should do
The short window may not limit exposure. Any unpinned install during that time pulled in a malicious version, Endor Labs said. Container images, CI caches, and lockfiles built in the window could still contain it. Removing the package does not undo the damage: "Removing the package stops future runs, but it doesn't undo anything that was already sent," Aikido said.
OX advised teams to check all environments, CI images, and lockfiles for either version and remove it. Teams should look for agent_framework_meta.pth and agent_framework_meta/_telemetry.py on hosts and build agents, the firm said. Version 1.26.2 used different files, af_runtime_diag.pth and af_runtime_diag.py, according to Aikido. If the package ran anywhere, every secret reachable from that host should be treated as compromised, OX said.
OX recommended rotating Azure service principal secrets, personal access tokens, and GitHub, npm, PyPI, NuGet, Docker, Hugging Face, and OpenAI tokens. The firm also advised teams to review Azure sign-in and activity logs for use of managed identities and federated credentials from affected build agents. OX recommended pinning the agent-framework to a verified Microsoft release with hash checking and blocking outbound traffic to webhook.site from build infrastructure.
Frequently asked questions
What did the malicious versions of Microsoft's agent-framework do?
They stole environment variables, credential files, and secrets from services like Azure, GitHub, and Docker, and requested fresh identity tokens from GitHub Actions, Azure DevOps, and Azure. The data was sent to an attacker-controlled webhook.
How long were the malicious versions live on PyPI?
The first version went up at 20:35 UTC and the second at 21:08 UTC on 17 November. Both were quarantined by about 21:20 UTC, less than an hour after the first appeared.
What should developers do if they installed the malicious versions?
Isolate affected environments, avoid running Python or pip until secured, rebuild from a known-clean environment using the safe 1.26.0 release, and rotate any potentially exposed credentials immediately.


