Trojanized Microsoft Agent Framework Builds on PyPI Targeted Azure and CI Credentials

| 5 min read

Two poisoned versions of Microsoft's Agent Framework package sat on PyPI for less than an hour in mid-November, long enough to turn routine installs into credential theft. Versions 1.26.1 and 1.26.2 went live on November 17 and were pulled quickly, but the payload had already been pulling cloud tokens, developer secrets and CI/CD credentials from laptops and build runners.

Here's the thing: the malware didn't break the framework. The malicious releases also installed the genuine code, so applications kept running normally. That made the compromise easy to miss. OX Security, one of several firms that flagged the releases, estimated the package gets about 192,534 downloads a month.

What the stealer took

The payload ran every time Python started, even if no code imported the package. It scanned environment variables whose names contained terms like TOKEN, SECRET, PASSWORD, KEY, AZURE, AWS, GITHUB and OPENAI. It 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 .env files. It also pulled secrets from up to 300 running processes.

It didn't stop at what was already on disk. Inside Azure DevOps pipelines, the code requested an identity token that can be exchanged for Azure access. It also requested managed identity tokens for Resource Manager, Microsoft Graph, Key Vault, Storage, Cognitive Services, AI Foundry and Azure DevOps.

The disguise was modest. The code sat in a module called _telemetry.py and reported under a user agent labeled "af-runtime-diagnostics." Stolen data left as compressed, encoded JSON sent to a webhook.site address.

A narrow window with a long tail

The first malicious release went up at 20:35 UTC on November 17 and the second at 21:08 UTC, according to Aikido Security. Both were gone by about 21:20 UTC. The attacker moved fast. OX reported that version 1.26.1 was reverted to the clean 1.26.0 while researchers were still analyzing it, and then 1.26.2 appeared with the same payload at a different file path.

Endor Labs found that both malicious versions were uploaded as wheel files only, without the source distribution that accompanied the clean release. That detail suggests the build process itself was hijacked rather than a maintainer's upload credentials simply being used. Microsoft hasn't confirmed how the attacker gained access, and it didn't immediately respond to a request for comment.

The short window shouldn't be read as limited exposure. Endor Labs noted that any unpinned install during that period would have pulled in a malicious build. Container images, CI caches and lockfiles generated in that window could still carry it.

Why AI pipelines are the target

OX argues the campaign shows attackers focusing on the AI developer ecosystem and the CI pipelines behind it. The target list reaches well beyond Azure, covering OpenAI and Hugging Face tokens and Azure AI Foundry access. AI tooling tends to be installed quickly, run with broad credentials and sit close to production model endpoints, which makes it an attractive entry point.

This isn't the first Microsoft Python package compromise this year. In May, Endor Labs detected three trojanized versions of durabletask, Microsoft's Python SDK for Azure Durable Functions. No researcher has tied the two incidents together.

What to do now

Uninstalling the package stops future runs but does nothing for data already sent. As Aikido put it, removing the package "doesn't undo anything that was already sent." Treat the exposure as a credential incident, not a cleanup task.

Start by checking every environment, CI image and lockfile for either version. Look for agent_framework_meta.pth and agent_framework_meta/_telemetry.py on hosts and build agents. Version 1.26.2 used different files, af_runtime_diag.pth and af_runtime_diag.py, per Aikido.

If the package ran anywhere, assume every secret reachable from that host is compromised. OX recommends rotating Azure service principal secrets, personal access tokens, and GitHub, npm, PyPI, NuGet, Docker, Hugging Face and OpenAI tokens. Review Azure sign-in and activity logs for use of managed identities and federated credentials from affected build agents. Pin the agent framework to a verified Microsoft release with hash checking, and block outbound traffic to webhook.site from build infrastructure.

The bigger lesson is about install hygiene. Unpinned dependencies turned a one-hour window into a real exposure, and that's a fixable problem. Teams that pin versions and verify hashes won't stop every attack, but they'll make the next poisoned upload a lot less useful to the attacker.

Source: Joseph Brown · www.csoonline.com