Microsoft’s AI Agent Package Hijacked on PyPI — a Credential Stealer That Ran on Every Python Start
Attackers compromised Microsoft’s official agent-framework package on the Python Package Index (PyPI) and used it to push a credential stealer, according to reports published November 18 by security firms Aikido, Chainguard, Endor Labs, OX Security, SafeDep, Socket, StepSecurity, and Google-owned Wiz. The malicious versions, 1.26.1 and 1.26.2, were published just 33 minutes apart on November 17, 2026. Both have since been quarantined on PyPI — but the attack is a warning shot for every developer building with AI tools: the supply chain behind the AI boom is now a prime target.
The package at the center of the incident is no obscure library. Agent-framework is the meta-package for Microsoft Agent Framework, an open-source framework for building and orchestrating artificial intelligence agents using Python. It attracts about 190,000 downloads a month. Anyone who installed or updated it during a roughly 45-minute window on Tuesday evening may have brought a thief into their environment.
What Happened
According to The Hacker News, which first detailed the compromise, the two malicious versions were published on November 17, 2026, 33 minutes apart. It remains unclear how the attacker managed to obtain publishing access to the official package — a question investigators and Microsoft will need to answer, because it determines whether this was a stolen credential, a hijacked build pipeline, or something else entirely.
What is clear is the mechanism. Both versions install Python startup hooks that silently collect credentials, environment data, and cloud identity tokens, then send them to an attacker-controlled endpoint, Socket reported. Once either version is installed, the package drops a .pth file in the site-packages root directory, which Python then executes automatically on every interpreter start. The credential stealer therefore runs whenever Python is started in an affected environment — even if the package is never explicitly imported.
“Each wheel adds a .pth file to site-packages,” Endor Labs said. “Python executes import lines in .pth files on every interpreter start, so the stealer runs on any Python launch in an affected environment, including pip itself, whether or not anything imports Agent Framework.”
The two versions used different filenames for their hooks: agent_framework_meta.pth in version 1.26.1, and af_runtime_diag.pth in version 1.26.2. The first file contains a single import statement referencing agent_framework_meta, which then launches the stealer payload. Version 1.26.2 went further, importing a new top-level module, af_runtime_diag.py, collecting GitHub Actions OIDC tokens, and expanding the search patterns used for harvesting credential-related environment variables.
What the Stealer Took
The haul was broad, and it went beyond passwords sitting in files. According to the reports, the stealer was capable of capturing environment variables matched by substring, credential files associated with Azure CLI (including ~/.azure/*.json), .npmrc, pip.conf, .netrc, .git-credentials, .docker/config.json, Hugging Face, Microsoft Azure DevOps agents, and .env and JSON files — plus Azure DevOps OIDC tokens, Azure managed-identity tokens, and Azure instance metadata, retaining up to 8,000 characters of the metadata response.
Crucially, the malware did not only read credentials already on disk. “Besides reading credentials already on disk, the code asks the platform to issue new ones,” SafeDep said. “Rotating stored secrets does not cover those.”
In an Azure DevOps pipeline, the SYSTEM_ACCESSTOKEN and SYSTEM_OIDCREQUESTURI environment values are enough to request a federated token for api://AzureADTokenExchange. On Azure compute, the stealer asks the managed identity endpoint for an access token for each resource — using IDENTITY_ENDPOINT or MSI_ENDPOINT on App Service and Functions, and the 169.254.169.254 metadata address elsewhere — and it also pulls instance metadata. The Azure instance metadata service is a RESTful web service that runs on that local IP address and provides information about the virtual machine, its region, tags, and identity token.
All of the collected information was saved into a JSON document, compressed with zlib, Base64-encoded, and sent via an HTTPS POST request to a hard-coded URL at webhook.site.
Who Is at Risk
With roughly 190,000 downloads a month, the exposure could be significant — though the window was short. Security researchers advise users to check for exposure to the malicious versions between 8:35 and roughly 9:20 p.m. UTC on November 17, 2026, and to take the following steps: isolate affected hosts and runners; pin the package to the most recent safe version, 1.26.0, and restore from a clean environment; search proxy and DNS logs for requests to the attacker’s webhook.site address; rotate exposed credentials from a clean system; audit Azure identities and review sign-in and activity logs; and audit GitHub Actions workflows that deploy to Azure.
The danger is not limited to individual developers. Agent Framework is used to build AI agents, which often run inside CI/CD pipelines with broad cloud permissions. A stealer that harvests pipeline tokens can turn one poisoned package install into access across an organization’s Azure estate — which is exactly why the researchers emphasize auditing identities and logs, not just reinstalling the package.
A Pattern, Not a One-Off
This is the second time this year that a Microsoft-related PyPI package has been compromised. In May 2026, the threat actors behind TeamPCP pushed three malicious versions of durabletask — Microsoft’s Python client for the Durable Task workflow execution framework — to distribute the Mini Shai-Hulud worm.
“The malicious agent-framework shows how attackers are targeting the AI developer ecosystem and the CI pipelines behind it,” OX Security said. “While directly targeting an official Microsoft package, it seems that attackers found a way to hijack the wheel creation flow to add malicious logic inside.”
The incident also lands in the same week as another major supply-chain attack. On November 16, attackers exploited a flaw in Optimizely Web Experimentation to inject malicious JavaScript into the websites of 178 organizations — including Zoom, the BBC, CNN, Salesforce, GitLab, and HSBC — swapping cryptocurrency wallet addresses, skimming payment card details, and pushing iOS exploit kits at visitors for about 17 hours before the code was largely cleaned up. Security researcher Scott Helme of Report URI, who discovered the campaign, found malicious code in 188 Optimizely snippets belonging to those 178 organizations. Trackers counted roughly $7,000 flowing into the attacker’s wallets on November 16. Optimizely confirmed the incident on November 17 and said the vulnerable path was blocked and the injected code removed, though its investigation continues.
Two different supply chains, two different techniques, one lesson: attackers no longer need to breach your company when they can breach something your company trusts.
What to Do Right Now
If you or your team use Microsoft Agent Framework, treat this as an active incident check, not a news item to file away:
- Check your version. If agent-framework 1.26.1 or 1.26.2 is installed anywhere — developer machines, build agents, containers — isolate those hosts and runners.
- Pin to 1.26.0 and rebuild from a clean environment. Do not just uninstall the bad version and assume the machine is clean; the .pth hook runs on every Python start, so the environment itself must be treated as compromised.
- Search your logs for requests to the attacker’s webhook.site address between 8:35 and about 9:20 p.m. UTC on November 17, 2026.
- Rotate credentials from a clean system — and remember SafeDep’s warning that the stealer could mint fresh tokens, so rotating stored secrets alone is not enough. Audit Azure identities, sign-in logs, and activity logs for anything unfamiliar.
- Audit GitHub Actions workflows that deploy to Azure, since version 1.26.2 specifically harvested GitHub Actions OIDC tokens.
- Lock down your own publishing. If you maintain a package, enable two-factor authentication on PyPI, use trusted publishing, and monitor your releases. The unanswered question in this incident — how the attacker got publishing access — is one every maintainer should be asking about their own packages.
The Bottom Line
A credential stealer hidden inside an official Microsoft package, running silently every time Python starts, is the supply-chain nightmare in its purest form: nothing looked wrong, nothing needed to be clicked, and the victims were developers doing exactly what they were supposed to do — installing a trusted library from the official registry. The exposure window was short, the package is quarantined, and the safe version is 1.26.0. But the two incidents in one week — Microsoft’s agent-framework and Optimizely’s 178 poisoned websites — show that attackers have moved decisively upstream, targeting the tools and platforms everyone else builds on. Check your versions, check your logs, rotate from a clean machine, and treat your build pipeline as part of your attack surface. Because that is exactly how the attackers now see it.
Sources: The Hacker News, “Attackers Compromise Microsoft’s Agent Framework PyPI Package to Steal Cloud Credentials” (November 18, 2026), reporting on findings from Socket, Endor Labs, SafeDep, OX Security, Aikido, Chainguard, StepSecurity, and Wiz; Cyber Kendra, “Optimizely Hack Confirmed: 178 Sites Hit, What to Do” (November 17, 2026); Dave Does Cyber Security, “Optimizely Web Supply Chain Attack: Executive Overview” (November 17, 2026).
Edited by Muse @QUE.COM
Website: https://QUE.COM Intelligence
Sponsored by: https://MAJ.COM AI Autonomous
Never miss a customer call again — MAJ.COM’s AI receptionist answers every call, texts customers back instantly, and books the appointment for you. See how it works at https://MAJ.COM
Discover more from QUE.com
Subscribe to get the latest posts sent to your email.
