# Microsoft's agent-framework on PyPI: the .pth file that stole cloud keys

> Two poisoned releases of Microsoft's agent-framework hit PyPI on 17 November 2026. How the .pth startup hook works, what it took, who was hit and what to check.

- Published: 2026-11-20
- Topics: AI security, Supply chain, AI agents
- Canonical page: https://thesecguy.com/notes/agent-framework-pypi-compromise-pth-credential-stealer/
- Publisher: The Sec Guy (https://thesecguy.com)

**Short answer:** On 17 November 2026, versions 1.26.1 and 1.26.2 of agent-framework, Microsoft's Python SDK for building AI agents, were published to PyPI with a credential stealer inside. A .pth file runs it every time Python starts in that environment, even if nothing imports the package. It collects environment variables, credential files and Azure and CI tokens and sends them to a webhook.site address. Version 1.26.0 is the last clean release. If either bad version was installed, delete its files without starting Python, rotate every secret that environment could reach, and rebuild.

---

Two releases of `agent-framework`, Microsoft's Python SDK for building AI agents, went up on PyPI on 17 November 2026 with a credential stealer inside. Versions 1.26.1 and 1.26.2 run it every time Python starts in the environment where they're installed, whether or not your code imports the package. If either one was installed on a laptop, a build runner or a container you own, treat every secret that environment could read as stolen.

Version 1.26.0, published on 12 November, is the last clean release.

This note is built from the researchers' own write-ups: [Endor Labs](https://www.endorlabs.com/learn/agent-framework-compromised-software-supply-chain-attack), [Chainguard](https://www.chainguard.dev/unchained/microsoft-agent-framework-compromised-on-pypi-november-2026), [Wiz](https://www.wiz.io/blog/malicious-version-of-microsofts-agent-framework-published-to-pypi), [JFrog](https://research.jfrog.com/post/agent-framework-hijack/) and [Socket](https://socket.dev/blog/agent-framework-pypi-package-compromised-with-credential-stealer). The reports we read on 20 November carry no explanation from Microsoft of how it happened.

## What happened

Version 1.26.1 was published at 20:35 UTC on 17 November. PyPI quarantined it. The attacker still had publishing rights and uploaded 1.26.2 at 21:08 UTC, 33 minutes after the first. Wiz says both versions were no longer available on PyPI as of 21:30 UTC.

So the bad releases were live for under an hour. That was long enough. JFrog saw dependency bots such as Renovate opening upgrade pull requests within six minutes of 1.26.1 landing, and Endor Labs puts the package at about 190,000 downloads a month.

Both uploads were wheels only, with no source distribution, and Chainguard notes that the GitHub source is not reported as modified. The poison was in the published package, so reading the repository would have shown you nothing.

<figure class="fig">
<p class="fig-k">The incident in four numbers</p>
<div class="tiles">
<div class="tile hot"><b>2</b><span>poisoned releases</span><small>1.26.1 and 1.26.2</small></div>
<div class="tile"><b>33 min</b><span>between the two uploads</span><small>20:35 and 21:08 UTC</small></div>
<div class="tile"><b>~190,000</b><span>downloads a month for the package</span><small>per Endor Labs</small></div>
<div class="tile"><b>3</b><span>victims whose data reached the attacker</span><small>counted by Wiz</small></div>
</div>
<figcaption>Sources: Endor Labs, Chainguard and Wiz. The download figure is for the package as a whole. Nobody has published a count for the two bad versions.</figcaption>
</figure>

## How a .pth file runs code you never imported

A `.pth` file is a small text file in Python's `site-packages` folder. Its normal job is to add folders to the import path. The [Python documentation](https://docs.python.org/3.16/library/site.html) describes one more thing it can do: "For backward compatibility, lines starting with `import` (followed by space or tab) are executed with `exec()`." That happens at interpreter startup, before your script runs.

The attacker shipped a `.pth` file with one such line. In 1.26.2 the file is 23 bytes long, per Chainguard.

From then on, anything that starts Python in that environment starts the stealer: `pip`, `pytest`, your editor's language server, a cron job. Installing the wheel doesn't run the code. The next Python command does.

Python 3.15 deprecated import lines in `.pth` files, but the same page says they are still executed during the deprecation period. Upgrading Python is not the fix today.

<figure class="fig">
<p class="fig-k">From pip install to stolen tokens</p>
<div class="flow">
<div class="node"><b>1. Install</b><span>pip, or a dependency bot, pulls agent-framework 1.26.1 or 1.26.2</span><div class="chips"><i class="chip">PyPI</i></div></div>
<div class="node"><b>2. Hook lands</b><span>A .pth file with one import line sits in site-packages</span><div class="chips"><i class="chip">.pth</i></div></div>
<div class="node"><b>3. Python starts</b><span>Any Python process in that environment runs the stealer</span><div class="chips"><i class="chip">no import needed</i></div></div>
<div class="node"><b>4. Collect</b><span>Environment variables, credential files, Azure and CI tokens</span><div class="chips"><i class="chip">secrets</i></div></div>
<div class="node"><b>5. Send</b><span>One HTTPS POST to a webhook.site address</span><div class="chips"><i class="chip">exfiltration</i></div></div>
</div>
<figcaption>Our layout of the steps described by Endor Labs, Chainguard, Wiz, JFrog and Socket.</figcaption>
</figure>

## What it took

The collector is aimed at cloud and build credentials. Across the write-ups, it gathers:

- environment variables whose names look like secrets (Endor Labs and JFrog count 31 name patterns in 1.26.1), which sweeps up model provider API keys along with cloud ones
- on Linux, the environments of other processes, up to 300 `/proc/*/environ` entries
- credential files under 256 KB each, up to 60 in 1.26.1 and 80 in 1.26.2: Azure CLI files, `.npmrc`, `.netrc`, `.git-credentials`, Docker config, `pip.conf`, Hugging Face tokens
- Azure managed identity tokens, requested from the instance metadata service at `169.254.169.254`
- an Azure DevOps OIDC token when the pipeline exposes one, and in 1.26.2 a GitHub Actions OIDC token as well

The last two matter most on build runners. An OIDC token is how your pipeline proves who it is to Azure, so the stealer was asking for the pipeline's identity as well as reading files.

Everything is packed into one JSON document, compressed, base64-encoded and sent in a single HTTPS POST to a webhook.site URL. Chainguard, JFrog and Socket all report no second-stage download, and JFrog found no persistence outside `site-packages`. Remove the files and the stealer is gone. The credentials it already sent are not.

## Who was hit

Wiz analyzed the requests that reached the attacker's webhook.site endpoint. It counted 50. Four came from the attacker's own machines, 29 appear linked to sandboxes, vendor scanning and tests, and the other 17 came from what Wiz calls "only three unique, successful cases of exfiltration of victim data."

<figure class="fig">
<p class="fig-k">The 50 requests the attacker's endpoint captured</p>
<div class="stack" role="img" aria-label="17 requests from three victims, 29 from sandboxes, scanners and tests, 4 from the attacker's own machines">
<span class="s-red" style="width:34%">17</span><span class="s-grey" style="width:58%">29</span><span class="s-amber" style="width:8%">4</span>
</div>
<ul class="legend">
<li><i class="s-red"></i><span><strong>17</strong> from victims (three unique cases)</span></li>
<li><i class="s-grey"></i><span><strong>29</strong> that appear linked to sandboxes, vendor scanning and tests</span></li>
<li><i class="s-amber"></i><span><strong>4</strong> from the attacker's own machines</span></li>
</ul>
<figcaption>Source: Wiz, update of 18 November 2026. This is what Wiz could see in the captured data, so read three as a floor.</figcaption>
</figure>

Three is a small number, and I wouldn't lean on it. If the package was installed in your environment during that window, you can't tell from the outside whether you're one of the three, and rotating is cheaper than guessing.

## How the attacker published under Microsoft's name

That part is still open. [SecurityWeek](https://www.securityweek.com/microsoft-agent-framework-releases-poisoned-with-credential-stealer/) reported on 18 November that the method remained unknown. Wiz's reading, added the same day, is that the attacker "appears to have compromised a client certificate and private key" for Microsoft ESRP (Engineering System Release Pipeline), and it adds that how those credentials were obtained is not yet known. Endor Labs says only that the uploads came from an account or token with publishing rights to the package.

That is why checking the package name would not have saved you. It was the real package, from the real publisher.

## What to do this week

1. Search for the two versions. Look in lockfiles, requirements files, CI logs, pip caches and any container image built after 20:35 UTC on 17 November for `agent-framework` 1.26.1 or 1.26.2.
2. If you find one, don't run `python` or `pip` there. Each start runs the stealer again, and `pip uninstall` is a Python start. Isolate the machine or runner, then delete the files with shell tools: `agent_framework_meta.pth` and `_telemetry.py` for 1.26.1, `af_runtime_diag.pth` and `af_runtime_diag.py` for 1.26.2. Rebuilding the environment from scratch is better.
3. Rotate every secret that environment could read or request: Azure identities and federated credentials, Azure DevOps and GitHub tokens, registry tokens, model provider API keys, anything in `.env` files. Then read the audit logs from the install time onward. Our note on [what attackers do with a leaked AWS key](https://thesecguy.com/notes/leaked-aws-key-first-5-minutes/) covers the same job on AWS.
4. Check egress logs for POSTs to `webhook.site/d381fd80-ec62-42ad-8f5c-d1b15103c9bb` and for the user agents `af-runtime-diagnostics/1` and `runtime-diagnostics/1`. Match the full path. webhook.site itself is a legitimate service.
5. Pin `agent-framework==1.26.0` with hashes (`pip install --require-hashes`) until Microsoft names a clean newer version.

Two habits would have blunted this one. Set a minimum release age in your dependency bot, so a version that is minutes old never reaches a pull request. And in GitHub Actions, give `id-token: write` only to the jobs that need it, so a poisoned dependency in a test job can't ask for a cloud token.

An agent framework is a good target for a stealer because of where it gets installed: next to model provider keys, cloud identities and pipeline tokens. The [Cursor breach](https://thesecguy.com/notes/cursor-breach-vendor-key-backdoored-extension/) reached developer machines through an editor extension. This one came through `pip install`.

---

**Sources** (all checked 20 November 2026)
- Endor Labs, "agent-framework compromised: Python startup hooks steal Azure and CI credentials", 17 Nov 2026: [endorlabs.com](https://www.endorlabs.com/learn/agent-framework-compromised-software-supply-chain-attack)
- Chainguard, "Microsoft agent-framework compromised on PyPI", 17 Nov 2026: [chainguard.dev](https://www.chainguard.dev/unchained/microsoft-agent-framework-compromised-on-pypi-november-2026)
- Wiz, "Microsoft agent-framework Compromised: Credential Stealer Targets Azure and CI Pipelines", 17 Nov 2026, updated 18 Nov: [wiz.io](https://www.wiz.io/blog/malicious-version-of-microsofts-agent-framework-published-to-pypi)
- JFrog Security Research, "Microsoft's agent-framework Hijacked on PyPI via Silent .pth Startup Hook", 18 Nov 2026: [research.jfrog.com](https://research.jfrog.com/post/agent-framework-hijack/)
- Socket, "Microsoft's agent-framework PyPI package Compromised with Credential Stealer", 17 Nov 2026: [socket.dev](https://socket.dev/blog/agent-framework-pypi-package-compromised-with-credential-stealer)
- SecurityWeek, "Microsoft Agent Framework Releases Poisoned With Credential Stealer", 18 Nov 2026: [securityweek.com](https://www.securityweek.com/microsoft-agent-framework-releases-poisoned-with-credential-stealer/)
- Python documentation, `site` module (path configuration files): [docs.python.org](https://docs.python.org/3.16/library/site.html)
