Two rogue releases of Microsoft's agent-framework package on PyPI dropped a startup hook that ran inside every Python process on the machine, from pip itself to test runners and container entrypoints. The second release went up two minutes after PyPI quarantined the first.
Key Takeaways
Most advice on poisoned packages assumes the danger begins when your code uses the package. Pin what you import, review what you call, and keep install scripts switched off. The two rogue releases of Microsoft's agent-framework that appeared on PyPI on November 17 skipped that assumption entirely. They did not touch the framework's own code at all. They added a single small file that Python reads on its own every time an interpreter starts, which meant the credential stealer ran inside pip, inside pytest and inside every container entrypoint on an affected host, whether or not anything imported the framework.
Agent-framework is the metapackage for Microsoft's toolkit for building AI agents and multi-agent applications, and SecurityWeek reports it draws about 190,000 downloads a month. The real SDK lives in agent-framework-core. Both malicious versions kept that dependency pinned to the clean 1.26.0, so applications kept working normally while the payload ran.
The payload itself rode in on a .pth file. JFrog Security Research explains that Python executes import lines in .pth files during site initialisation, before sitecustomize or any user script, so any Python process triggers it: pip, pytest, IDE language servers and container entrypoints alike. Version 1.26.1 used a 28-byte agent_framework_meta.pth and also appended a call to the package's own __init__.py. Version 1.26.2 restored that file byte for byte and moved the hook to af_runtime_diag.pth, so a diff of the package's module against the clean release would pass. On Linux and macOS the collector forks and detaches from the parent, and nothing is written to disk to mark that it has run, so it fires again on every new interpreter.
That has an uncomfortable consequence for cleanup. Endor Labs warns that the collector runs again on every interpreter start, including during pip uninstall, so the reflex of removing the bad version with pip hands the stealer one more run. Its guidance is to isolate the host, remove the payload files without launching Python, and prefer rebuilding to cleaning in place.
Endor Labs' analysis lists the haul. The stealer matched environment variables against 31 name fragments, among them TOKEN, SECRET, KEY, AZURE, AWS, GITHUB and OPENAI, and read up to 300 entries of other processes' environments. It copied up to 60 credential files in 1.26.1 and 80 in 1.26.2, covering Azure CLI token caches, .npmrc, .netrc, .git-credentials, Docker configs, Hugging Face tokens and Azure DevOps agent credentials. It requested Azure managed identity tokens for 12 resources and, where SYSTEM_ACCESSTOKEN was present, an Azure DevOps OIDC token. Version 1.26.2 added GitHub Actions OIDC tokens and GitHub-hosted runner paths. Everything was compressed, base64-encoded and posted to a webhook.site URL, with no protection beyond TLS.
The attacker also made mistakes. JFrog found that webhook.site began returning HTTP 429 rate-limit errors, so only early victims' data was accepted, and that the Azure DevOps OIDC request was malformed and failed with HTTP 400, although the access token still leaked through the environment. It also found that 33 of the 35 file patterns were absolute Linux paths, so macOS developer machines leaked environment variables and Azure token caches but not every credential file the stealer was looking for.
“Removing one version did not stop an attacker who could still publish.”
SafeDep
The timeline is the part security teams should study. Endor Labs records 1.26.1 going up at 20:35 UTC and 1.26.2 at 21:08, 33 minutes apart. JFrog places PyPI's quarantine of 1.26.1 at 21:06, 31 minutes after upload, and the second release two minutes after that, with both releases removed by 21:16. It also found that Renovate bots had opened upgrade pull requests in downstream repositories within six minutes of 1.26.1 landing, so automation was pulling the bad version forward long before any human had looked at it.
Neither release came from Microsoft's build system. JFrog's analysis of the archive shows the clean wheel was repacked locally with Info-ZIP on a host set to UTC+8, bypassing Microsoft's Azure DevOps and ESRP release pipeline. Endor Labs notes the giveaway in the packaging: both malicious releases shipped only a wheel, while every release from 1.21.0 through 1.26.0 included a source distribution as well. SafeDep found a second maintainer on the project, an account named vibiret that joined PyPI on the day of the attack and can publish to agent-framework and five sibling projects, four of which install alongside 1.26.0. No upload log confirms it was the uploader, and SafeDep calls this the second Microsoft package on PyPI with rogue releases in six months, after durabletask in May.
Microsoft has said little so far. BleepingComputer had no response to questions about how publishing access was obtained, and SecurityWeek reports that a maintainer confirmed in a GitHub discussion that the releases were removed and an investigation is under way.
Install-time controls and import reviews both assume code has to be called before it can run. A .pth file needs neither: arriving in site-packages is enough. The two minutes between quarantine and the next upload show the other half of the lesson, which is that removing a bad version deals with the package while the publishing credential behind it stays live. Until a registry knows that a release came out of its maintainer's real pipeline, the safest assumption is that the newest version of anything is the one to wait on.
Whitepaper
Renovate bots proposed the poisoned agent-framework upgrade within six minutes, faster than any manual review, and this whitepaper sets out where automated scanning and policy gates belong in a CI/CD pipeline so a release like that is stopped before it merges.
Download
Datasheet
Agent-framework is a metapackage whose real code sits in sibling packages, and this datasheet covers how software composition analysis maps those nested open source components so you can tell which applications pulled in 1.26.1 or 1.26.2.
Download
eBook
This attack borrowed the name of Microsoft's own AI agent toolkit to harvest exposed cloud tokens, and this ebook draws on Huntress SOC cases to show how attackers turn trusted AI tools and old credential gaps into a way in.
Download
Sonatype found a loader in 12 hijacked npm releases, and none of them used an install hook a script policy could block.
Alpine Linux patched a CVSS 10 GitLab flaw twice and stayed exposed, because the fix sat in GitLab's bundled Ruby.
An AI pipeline found 948 kernel flaws for about $1,279 each, and fixes are reaching maintainers far slower than the bugs were found.