Official Microsoft agent-framework PyPI package compromised
Microsoft's agent-framework PyPI package was compromised in versions 1.26.1 and 1.26.2 to harvest cloud tokens and system credentials via startup hooks.
By Dillip Chowdary • Nov 19, 2026 • Source: opensourcemalware.com

At a glance
- Product
- Microsoft agent-framework
- Compromised versions
- 1.26.1 and 1.26.2
- Ecosystem
- Python Package Index (PyPI)
- Publisher status
- Quarantined by PyPI registry
- File size limit
- 256 KiB per harvested file
- Exfiltration endpoint
- webhook.site destination
In this post
Two malicious releases of Microsoft's agent-framework package on PyPI, versions 1.26.1 and 1.26.2, introduced an automated credential stealer into the official supply chain. According to opensourcemalware.com's report, the threat actor published both artifacts using Microsoft's legitimate PyPI publisher account rather than relying on typosquatting. The embedded malware triggers automatically whenever the Python interpreter initializes in an infected environment, collecting secrets without requiring developer code to import the package.
This report details the architectural anatomy of the supply chain compromise, the extraction mechanisms across developer systems, and the ongoing publisher quarantine. The analysis serves engineering teams, site reliability professionals, and platform security architects managing Python dependencies or cloud continuous integration runners. Readers will find exact file targets, authentication scopes, network endpoints, and verification steps necessary to identify compromised environments.
01Compromised official publisher account and quarantine
The compromised agent-framework artifacts emerged from Microsoft's genuine publishing identity on the Python Package Index rather than an unauthorized lookalike project. Because the upload originated from the verified publisher, project locks, existing hash controls, and historical package trust failed to protect environments resolving versions 1.26.1 and 1.26.2. PyPI administrators quarantined the publisher account after detecting version 1.26.1, yet the threat actor retained access and released version 1.26.2.
The unpacked release masquerades as standard project tooling, incorporating Microsoft authorship metadata and documentation alongside an agent_framework_meta package directory. Alongside those expected assets sit af_runtime_diag.pth and af_runtime_diag.py, which masquerade as diagnostic modules while actually gathering local secrets. Public PyPI download metrics reflect general interest across historical releases but do not establish how many developers downloaded the poisoned versions.
Note: Treat any installation of version 1.26.1 or version 1.26.2 as a full system credential compromise, even if the registry publisher account is restored or a clean release appears later. Security teams must rotate every secret resident on affected developer workstations, continuous integration runners, and connected cloud identity services immediately.
02Silent interpreter execution through pth hooks
Execution relies on a 23-byte startup hook placed inside the standard site-packages directory under the filename af_runtime_diag.pth. Python site initialization executes import statements embedded within path configuration files whenever the interpreter initializes. Because this automatic loader imports the af_runtime_diag module immediately, the credential stealer executes before application code loads and without explicit project imports.
At initialization, the module invokes an internal start function that sets an environment flag named _AF_TEL to one to prevent duplicate execution across subprocesses. The routine then attempts to spawn a detached forked background child to isolate the collector from application workflows. When operating systems prevent process forking, the script launches a background daemon thread while broad exception handling suppresses visible errors throughout execution.
03Local environment secrets and file inspection
Advertisement
Tech Pulse Daily
Get tomorrow's pulse first
Join engineers who read Tech Pulse before stand-up. Free, weekday mornings.
The collection engine immediately inspects local execution context, cataloging the hostname, current username, active working directory, and the initial twenty command-line arguments alongside system timestamps. It scans process environment variables against keyword filters targeting sensitive strings including TOKEN, SECRET, PASSWORD, KEY, AZURE, AWS, GITHUB, OPENAI, FOUNDRY, PIP, NPM, and NUGET. It also searches for cloud tags covering COSMOS, STORAGE, TENANT, CLIENT, IDENTITY, and MSI.
File collection inspects hard-coded paths and glob patterns across the host filesystem, reading files smaller than 256 KiB up to an eighty-file boundary. Target files include Azure CLI JSON records, Docker config.json, Hugging Face tokens, Git credential stores, pip.conf, .npmrc, and .netrc assets. The routine also extracts local application environment files, Foundry configurations, Azure Pipelines agent credentials, and up to 300 /proc process environment files.
04Fresh cloud identity and runner tokens
Rather than relying exclusively on dormant credentials stored on disk, the stealer actively queries local infrastructure endpoints to mint fresh tokens. In GitHub Actions environments providing ACTIONS_ID_TOKEN_REQUEST_URL, the malware requests OIDC tokens for the api://AzureADTokenExchange and Azure management audiences. The script authorizes requests using the ACTIONS_ID_TOKEN_REQUEST_TOKEN environment variable and falls back to ACTIONS_RUNTIME_TOKEN whenever necessary.
Azure DevOps pipelines face credential harvesting whenever SYSTEM_OIDCREQUESTURI and SYSTEM_ACCESSTOKEN variables appear, sending POST requests to the version 7.1 OIDC endpoint for Azure token exchange scopes. When running in Azure virtual environments, the script queries IDENTITY_ENDPOINT, MSI_ENDPOINT, or the metadata service at 169.254.169.254. It requests access tokens across Azure Cognitive Services, Azure Search, Azure Storage, Key Vault, Graph, and Container Registry.
05Compressed webhook exfiltration and payload limits
The malware bundles captured data into a unified JSON object, compresses the payload using zlib compression at level 9, and encodes the bytes with Base64. It transmits the payload using an HTTPS POST request directed to a dedicated webhook.site destination endpoint. The outbound request mimics legitimate network diagnostics by specifying a custom user agent named runtime-diagnostics/1 and appending a telemetry URL query parameter.
Static analysis confirms the package functions as a focused credential stealer rather than a persistent backdoor or remote access trojan. The code contains no subprocess launchers, command interpreters, dynamic payload downloaders, or secondary binary drops. Stolen token responses returned from cloud identity endpoints are stored exclusively in memory for exfiltration, while all incoming HTTP responses returned by the remote webhook destination are discarded.
Security researchers documented the complete attack sequence from initial package installation through cloud identity harvesting and remote delivery. The supply chain vector bypasses traditional runtime import guards by attaching directly to interpreter initialization hooks, executing background threads, and exfiltrating developer credentials before application logic begins. The documented behavior outlines the sequential progression across victim systems:
| Stage | Behavior | Result |
|---|---|---|
| Package installation | Malicious .pth file is placed in site-packages | Startup hook established |
| Python startup | File af_runtime_diag.pth imports af_runtime_diag | Stealer starts automatically |
| Background execution | Forked child or daemon thread runs | Collection detached from application |
| Local collection | Environment, files, arguments and /proc inspected | Developer and CI secrets captured |
| Token acquisition | GitHub, Azure DevOps and Azure endpoints queried | Fresh OIDC and cloud tokens captured |
| Exfiltration | Compressed, Base64 JSON payload posted | Stolen material reaches remote webhook |
Frequently asked questions
Which versions of the agent-framework package are malicious?
Versions 1.26.1 and 1.26.2 contain credential-stealing code. Both versions were published through Microsoft's legitimate PyPI account.
How does the malware execute without being imported?
The package places af_runtime_diag.pth into site-packages. Python automatically executes import lines inside path configuration files during interpreter initialization.
What credentials does the stealer target?
The script collects environment variables, up to 80 local files under 256 KiB, and up to 300 /proc process environments. It also requests fresh OIDC and identity tokens from GitHub Actions, Azure DevOps, and Azure metadata endpoints.
Where does the stolen data get sent?
The data is serialized to JSON, compressed with zlib level 9, Base64-encoded, and sent via HTTPS POST to a webhook.site URL. It does not download secondary payloads or establish operating system persistence.
Sources
Author
Dillip Chowdary
Writes Tech Bytes coverage of AI, engineering, and the tools that actually ship. Editor of Tech Pulse Daily.
Related on Tech Bytes
Advertisement