Thursday, November 19, 2026

Microsoft agent-framework on PyPI Was Trojanized: What the .pth Hook Stole

Two malicious releases of Microsoft's agent-framework package, versions 1.26.1 and 1.26.2, were published to the Python Package Index (PyPI) on November 17, 2026, carrying a credential stealer that runs every time Python starts. The package is the official Python distribution of Microsoft Agent Framework, a toolkit for building AI agents, and it draws roughly 40,000 downloads a week. Both versions were pulled within about an hour, but anyone who installed them should treat every secret on that machine, container or CI runner as stolen. The last clean release is 1.26.0.

An hour is a short window. It's also long enough. Automated dependency bots, nightly builds and fresh container images don't wait for anyone to read a changelog, and an unpinned pip install agent-framework during that stretch would have pulled the poisoned build without a single warning.

What happened to Microsoft's agent-framework package on November 17

According to Wiz, which published a detailed timeline, version 1.26.1 landed on PyPI at 20:35 UTC. Version 1.26.2 followed at roughly 21:08 UTC. JFrog's researchers noted that the second release appeared about two minutes after the first had been quarantined, which tells you something important: PyPI quarantining a version does not take away the credential that published it. The attacker simply shipped another one. GitHub's advisory database lists the incident as GHSA-764m-3ppc-5m73 and, pointedly, shows no patched version. The fix is to avoid both releases entirely.

The packaging itself was quiet work. JFrog concluded the attacker rebuilt the clean wheel locally, outside Microsoft's release pipeline, and slipped in a few extra files. A wheel, for anyone outside the Python world, is the prebuilt archive pip installs; nobody compiles anything, so whatever is in the archive lands on disk as is. GitHub's advisory names only the top-level agent-framework package, and its affected range is exactly those two versions: 1.26.0 and everything before it are clean.

How a .pth startup hook runs malware without an import

This is the part defenders should sit with for a minute. Python's startup routine, site.py, reads every .pth file in the site-packages directory when the interpreter launches. These files were designed to add paths to the module search list, but any line that begins with import gets executed. So a one-line .pth file becomes an autorun entry for every Python process on the system.

That means the payload doesn't care whether your code ever touches agent-framework. A pytest run fires it. So does a linting hook, a Jupyter kernel, or an unrelated script that happens to share the same virtual environment.

Version 1.26.1 used a file called agent_framework_meta.pth to trigger a collector named _telemetry._start(). On Linux and macOS it forks and detaches into its own session; on Windows it uses a background daemon thread. An environment variable, _AF_TEL=1, stops child processes from launching it again. Version 1.26.2 was more careful. It restored the original __init__.py and moved the hook into a new top-level pair, af_runtime_diag.pth and af_runtime_diag.py. Socket made the practical point: anyone who only checked the package's own init file for tampering would have found nothing wrong. The names were chosen to look like routine SDK telemetry and diagnostics, which is exactly what a tired reviewer expects to see.

Which credentials the agent-framework stealer collected

The shopping list was broad. Per the analyses from Wiz, JFrog and Socket, the collector grabbed environment variables whose names matched secret-like substrings such as TOKEN, KEY, SECRET, AZURE, AWS, GITHUB, OPENAI and HF_. JFrog counted 31 substrings and observed that the matching is loose enough to sweep up keys like ANTHROPIC_API_KEY and GEMINI_API_KEY too. On Linux it also read the environment of up to 300 other running processes through /proc. It went after credential files on disk: Azure CLI token caches, .npmrc, .netrc, .git-credentials, Docker configs, Hugging Face tokens, application .env files and Azure DevOps agent credential stores, up to 60 files in the first version and 80 in the second.

Then it asked for more. Rather than settling for what was lying around, the code requested fresh managed identity tokens (credentials Azure issues to a workload so it can call other Azure services without a stored password) for 12 Azure resources from the instance metadata service. Version 1.26.2 added GitHub Actions OIDC tokens, short-lived identity tokens a workflow can trade for cloud access, in any pipeline granted the id-token: write permission.

Everything was bundled into one JSON document, compressed with zlib, base64-encoded and sent in a single HTTPS POST to a hardcoded webhook.site address. No encryption, no retry, no fallback channel.

Why AI agent toolkits make such good supply-chain targets

Here's the angle I think gets missed in the indicator lists. An agent framework is a near-perfect host for this kind of theft, and it's not a coincidence. Agents exist to call things: model APIs, cloud services, databases, ticketing systems, code repositories. So the environments where agent code runs are dense with exactly the keys this stealer hunted. A developer laptop prototyping an agent may hold an OpenAI key, an Azure subscription login, a GitHub token and a Hugging Face token all at once. A CI runner testing that agent often holds the deployment credentials as well. The attacker didn't need to understand agents. They needed to understand where agents keep their keys.

Wiz added a twist that matters. The attacker's own tooling, which Wiz identified as Cairn, an open-source AI penetration testing framework, reported its progress to the same public webhook used for exfiltration. That slip exposed part of the operation. Wiz also reported that the attacker appears to have obtained a client certificate and private key for Microsoft's ESRP signing and publishing service, that a first publishing attempt from AWS was blocked by IP filtering, and that a second attempt from Microsoft-owned IP space succeeded. How those credentials were obtained is not known yet. Wiz mentioned an earlier compromise of a separate Microsoft package, durabletask, this year, but has not linked the two. I'd hold off on drawing a line between them until someone with evidence does.

The operator also made mistakes that limited the damage. Wiz confirmed the webhook.site token sat on the free tier, which accepts at most 100 requests, and that it captured 50. Of those, Wiz attributed four to the attacker's own machines, 29 to sandboxes, scanners and tests, and 17 to three unique successful thefts of victim data. Three victims is a small number. For those three, it is not small at all.

What to check and rotate if you installed agent-framework 1.26.1 or 1.26.2

Start by finding out whether you're affected. Search lockfiles, CI logs, virtual environments, internal package mirrors and container images built on November 17 for either version. JFrog specifically suggests reviewing Dependabot and Renovate pull requests opened that day, since a bot happily proposing an upgrade to 1.26.2 is a plausible path in. Then look in site-packages for agent_framework_meta.pth, af_runtime_diag.pth or af_runtime_diag.py, and check proxy and DNS logs for POSTs to webhook.site carrying ?t=telemetry. Wiz notes that a 200 response suggests the data was accepted, while 410 or 429 suggests it was turned away.

Cleanup has a trap in it. Running pip to uninstall the package starts Python, which fires the hook one more time. JFrog's advice is to set _AF_TEL=1 in the shell before running any Python command so the payload stands down, delete the malicious files, uninstall, and pin agent-framework==1.26.0. Rebuild container images rather than patching them, because an image carrying the bad version runs the stealer on every container start.

Then rotate. All of it. Cloud credentials, model provider API keys, package registry tokens, git credentials, Azure DevOps personal access tokens and service connections. Re-register self-hosted Azure DevOps agents, revoke Entra ID sessions where Azure CLI caches existed, and review managed identity sign-in logs, since tokens issued before rotation can stay valid for up to 24 hours. For GitHub Actions workflows that installed 1.26.2 with id-token: write, treat the OIDC tokens as exposed and review the federated credentials they map to.

Longer term, two habits would have blunted this. Pin exact versions with hashes in lockfiles so a new release can't arrive unannounced, and give new releases a cooling-off period in your internal mirror before builds can consume them. Most poisoned packages are caught within hours. A one-day delay costs you almost nothing and would have made this one a non-event. I'd also add a simple scheduled check that flags any new .pth file containing an import line in production environments; legitimate ones are rare enough that every hit deserves a look.

The broader lesson is a familiar one wearing new clothes. Agent frameworks are moving fast, release often and sit in environments full of keys. Treat them with the same suspicion you'd give any dependency that runs with your credentials, because that's what they are.

References

GitHub. (2026, November 18). Malicious code in agent-framework (PyPI) (GHSA-764m-3ppc-5m73). GitHub Advisory Database. https://github.com/advisories/GHSA-764m-3ppc-5m73

Satou, S. (2026, November 18). Microsoft's agent-framework hijacked on PyPI via silent .pth startup hook. JFrog Security Research. https://research.jfrog.com/post/agent-framework-hijack/

Socket Research Team. (2026, November 17). Microsoft's agent-framework PyPI package compromised with credential stealer. Socket. https://socket.dev/blog/agent-framework-pypi-package-compromised-with-credential-stealer

Wiz Research. (2026, November 17). Microsoft agent-framework compromised: Credential stealer targets Azure and CI pipelines. Wiz. https://www.wiz.io/blog/malicious-version-of-microsofts-agent-framework-published-to-pypi