Microsoft’s Agent Framework PyPI Package Hijacked to Steal Azure and CI Credentials

Malicious versions 1.26.1 and 1.26.2 of Microsoft's agent-framework package on PyPI ran a credential stealer on every Python start, targeting Azure, Azure DevOps and GitHub Actions secrets.
Microsoft logo overtop neon blue abstract cyber background.

Attackers published two malicious versions of agent-framework, Microsoft’s official Python package for building AI agents, to the Python Package Index (PyPI) on November 17. Versions 1.26.1 and 1.26.2 carried a credential stealer aimed at Azure, Azure DevOps and GitHub Actions, according to a GitHub security advisory and analyses from several security firms.

PyPI has quarantined both releases. Version 1.26.0, released on November 12, is the last clean version. The package gets about 41,000 downloads a week, Wiz said, and roughly 196,000 a month, according to Mend. Those figures cover all versions. How many times the two bad releases were installed is not known.

Two releases in 33 minutes

The first malicious version went up at 20:35 UTC (3:35 PM ET) as a wheel file only. StepSecurity said PyPI quarantined it at 4:06 PM ET. Just over two minutes later, at 4:08 PM ET, the attacker uploaded 1.26.2 with renamed files and new features. PyPI quarantined that release eight minutes later.

The second upload shows the attacker still had publishing access after the first release was pulled. OX Security called it a planned, live effort to reach as many victims as possible.

How the stealer runs

Each wheel adds a one-line .pth file to the site-packages folder. Python runs these files every time the interpreter starts, so the stealer fires whenever Python launches in that environment, even if no code ever imports the framework. Running pip or pytest is enough.

In 1.26.1, the files are agent_framework_meta.pth and agent_framework_meta/_telemetry.py, started from a block added to the package’s __init__.py. In 1.26.2, the attacker restored that file to its clean state and moved the code into af_runtime_diag.pth and af_runtime_diag.py. Searching only for the first file names will miss it.

Posing as runtime diagnostics, the code forks into a detached background process, sets the marker _AF_TEL=1 so it runs once per process tree, and hides every error. The rest of the package matches 1.26.0, so the framework keeps working normally.

What it steals

The stealer collects:

  • Environment variables with names containing words such as TOKEN, SECRET, PASSWORD, KEY, AZURE, AWS, GITHUB and OPENAI.
  • Secrets from the environments of up to 300 other processes, read through /proc/*/environ.
  • Up to 60 credential files (80 in 1.26.2), including Azure CLI files, .npmrc, .netrc, .git-credentials, Docker and pip settings, Hugging Face tokens, Azure DevOps agent credentials and .env files.
  • Fresh Azure managed identity tokens for 12 resources, requested from the instance metadata service, including Azure Resource Manager, Key Vault, Storage, Microsoft Graph and Container Registry.
  • Azure DevOps OIDC tokens, and in 1.26.2, GitHub Actions OIDC tokens that can be traded for Azure access where a federated trust exists.

Everything is compressed, base64-encoded and sent in one HTTPS POST to a hard-coded URL on webhook[.]site, a free request-capture service. Wiz said the attacker’s endpoint was on the free tier, which accepts at most 100 requests, and that no more than 50 requests were captured. Those requests could still hold working cloud, CI and registry credentials.

How the attacker got in

The root cause has not been confirmed. Wiz found no 1.26.1 tag or release in Microsoft’s source repository and no malicious code on its main branch. Real releases ship a wheel and a source archive together, so the wheel-only uploads suggest they were built outside the normal release process. StepSecurity said both uploads carried a RestSharp uploader user-agent.

The PyPI project page lists a second maintainer account alongside Microsoft. SafeDep said that account was created on November 17, the day of the attack, and can also publish to five related agent-framework projects. SafeDep said neither PyPI nor Microsoft has confirmed it uploaded the bad releases.

Microsoft had not issued a formal public statement or security advisory at time of publication. On Wednesday morning, the microsoft/agent-framework GitHub repository, where the first release was reported in an issue, returned a “not found” error.

Part of a wider pattern

This is not the first Microsoft package hit on PyPI this year. Wiz and SafeDep noted that rogue releases of durabletask were pushed in May with a stolen PyPI token, though no link between the two incidents has been found. The .pth trick also appeared last month when LiteLLM was hit by a second supply chain attack, and CI secrets were the target of the recent wfx-loot campaign on hijacked GitHub accounts and the Mini Shai-Hulud malware. GitHub’s advisory said the agent-framework attack has not been tied to a known campaign.

What to do now

  • Search lockfiles, CI logs, virtual environments, caches and container images for agent-framework 1.26.1 or 1.26.2.
  • Delete agent_framework_meta.pth and af_runtime_diag.pth from site-packages before running pip, since starting pip runs the stealer again. Then reinstall and pin agent-framework==1.26.0 and rebuild affected images.
  • Check proxy and DNS logs for requests to webhook[.]site with the User-Agent af-runtime-diagnostics/1 or runtime-diagnostics/1.
  • Rotate every secret the affected host or pipeline could reach, including Azure DevOps tokens, service connections, and npm, PyPI, NuGet, Docker and Hugging Face tokens.
  • Review Microsoft Entra ID sign-in logs from November 17 for managed identities and federated credentials used by affected machines. Rotating stored secrets does not cancel tokens already issued.

Full indicators, including file hashes, are listed in the GitHub advisory and the Wiz, Mend and StepSecurity reports.

Picture of m00s3c

m00s3c

Moose (@m00s3c) is the author of BreachNews, focusing on data breach intelligence, dark web monitoring, and threat analysis. His work involves analyzing breach claims, reviewing leaked datasets, and tracking threat actor activity to provide clear, factual reporting.

Latest News

BREACHNEWS.COM/SUPPORT/

Support Independent News.

Help support breach monitoring, investigations, infrastructure, and reporting.

Support the site →