Microsoft’s Agent Framework PyPI Package Hijacked to Harvest Azure & GitHub Secrets

Microsoft’s widely used Python package *agent-framework* was compromised when two malicious versions—1.26.1 and 1.26.2—were published on PyPI on November 17, 2026, embedding code designed to steal credentials tied to Azure and GitHub. This malicious code was active even in projects that never directly imported the compromised package. By 21:30 UTC those releases had been removed from PyPI. Version 1.26.0 remains the latest confirmed clean build. This package sees about 41,000 downloads per week in total.

How the Attack Worked

Both rogue versions placed a “.pth” file into Python’s site-packages directory, the standard location for installed libraries. Python processes these files at startup, executing any included code even if the package isn’t explicitly imported in a project. That enabled silent credential harvesting in environments where the package was present. Each version used distinct file names and structures to enable this, though both transmitted data to the same server.

Version 1.26.1 introduced two new components—a malicious .pth file named agent_framework_meta.pth and a collector module _telemetry.py. In version 1.26.2, the package’s original initializer was restored and the malicious payload moved into af_runtime_diag.py, with a corresponding .pth file trigger (af_runtime_diag.pth). These structural changes mean that simple checks for Version 1.26.1’s files could miss the later malicious version.

Scope of Data Targeted & What Was Sent

The malware gathered environment variables, readable process metadata, and local files to search for secrets—to include Azure CLI credentials, Azure DevOps agent credentials, Docker and npm configuration data, Git credential stores, and any secret or .env file in use. Version 1.26.2 also targeted GitHub Actions workflows by requesting OpenID Connect (OIDC) tokens. Such tokens, if trusted by Microsoft Entra ID in the context of a workflow, may allow attackers to gain access to Azure under the permissions of that identity.

Data extracted was compressed, encoded, and sent to a third-party webhook site during the attack window. Even a single accepted request back could bundle multiple exposed secrets—tokens, cloud credentials, or registry credentials. Security teams warn that the number of captured webhook requests may not reflect the total number of compromised systems.

Advice & Mitigation Steps

Organizations using Python should audit dependency lockfiles, build logs, virtual environments, container images, and cached packages to detect presence of either 1.26.1 or 1.26.2. If evidence of compromise exists, isolate impacted environments. Disable or avoid execution of Python there.

Further action includes revoking or rotating credentials that were accessible, reviewing Azure sign-in and activity logs for suspicious service connections or managed identity use, and in GitHub Actions context checking Entra ID trust settings for workflows that allow OIDC token writing. Finally, upgrade or pin agent_framework to version 1.26.0, and rebuild environments from trusted sources.

The breach of Microsoft’s Agent Framework reveals that even standard process mechanisms like Python’s startup scripts can be weaponized to exfiltrate high-value secrets. With cloud credentials and build systems the target, this incident underscores the urgency for rigorous supply chain security— especially in dependencies that many teams take for granted. Keep a close eye on trust configurations in identity systems, audit your pipelines, and treat third-party packages as potential attack vectors rather than assumed safe.