SecurityIntermediate

The PyPI Compromise: Supply-Chain Defense That Works

DeveloperHat Team
23 min read

TL;DR

Two poisoned agent-framework releases stole cloud credentials for under an hour on November 17, 2026. What happened, why pinning alone would not have saved you, and the defenses that do.

On November 17, 2026, two releases of agent-framework — the PyPI meta-package for Microsoft Agent Framework, an open-source SDK for building AI agents — shipped with a credential stealer baked in. Version 1.26.1 was live for about 55 minutes, and 1.26.2 for about 22 minutes, before both were pulled from PyPI by about 21:30 UTC; 1.26.0 is the last safe release. If you installed either poisoned version, the question is whether any credentials in that environment were harvested, and what you have done about it since.

The uncomfortable part is how little of the standard advice would have helped. The packages were published through what appears to have been a legitimate release pipeline, and the payload did not wait for anyone to import the package — it ran every time Python started. This article works through what happened, why each familiar defence would or would not have caught it, and the layered controls that do work, in the order to build them.

Fifty-five minutes on PyPI was enough — the window was the attack 20:35 UTC — 1.26.1 poisoned wheel + .pth .pth runs at start no import needed Harvests credentials env · files · tokens 21:08 UTC — 1.26.2 adds GitHub OIDC Single POST webhook.site exfil 21:30 UTC — pulled 3 victims confirmed The payload ran on every Python start — the install was the compromise.

What happened on November 17

Version 1.26.1 was published at about 20:35 UTC on November 17, 2026, and stayed live for about 55 minutes. Version 1.26.2 followed at about 21:08 UTC and was live for about 22 minutes. Both were off PyPI by about 21:30 UTC. A maintainer confirmed in GitHub issue #10411 that the versions had been pulled and an investigation was under way. Microsoft has not published a root cause, and some repositories — including microsoft/agent-framework and microsoft/onnxruntime — were made private.

The package gets roughly 190,000–200,000 downloads a month according to Anomali, and Wiz cites about 41,000 downloads a week — so even a window of under an hour reaches real installs, as CI jobs, scheduled builds, and developers installing by hand run continuously across time zones.

Both poisoned releases were rebuilt from the legitimate 1.26.0 wheel with a single addition: a .pth file (agent_framework_meta.pth in 1.26.1, af_runtime_diag.pth in 1.26.2). Everything else was the real release — which is why the usual signals, a plausible version number, a familiar name, a matching changelog, all looked normal.

The incident is catalogued as PYSEC-2026-4388, GHSA-764m-3ppc-5m73, and MAL-2026-20101. Only the agent-framework meta-package was affected — sibling packages such as agent-framework-core were not touched, and no npm package was published — and it is the second Microsoft-related PyPI package compromised in 2026.

Primary sources: Wiz's write-up of the incident, the OSV entry PYSEC-2026-4388, and The Hacker News coverage.

How a .pth file turns a package into a trigger

Python processes .pth files found in site-packages at interpreter start. A .pth file can add directories to sys.path — and, crucially, lines beginning with import are executed. That means code referenced by a .pth file runs every time the interpreter starts in that environment, before any of your code runs and whether or not anything imports the package that shipped it.

That defeats a whole way of thinking about supply-chain risk. Most engineers model a malicious dependency as dangerous when imported: you install it, your code imports it, the payload runs, and a package you never import is inert. A .pth payload breaks that model entirely — it ran on every Python start in an affected environment, regardless of whether anything imported agent-framework.

That has two practical consequences. First, the trigger condition was not "your application uses the Microsoft Agent Framework" — it was "your environment installed the poisoned version and then ran Python." A CI runner that installed the package as a transitive dependency, or a developer machine where it sat unused in a virtual environment, was still exposed every time Python started there. Second, the payload was invisible to the normal signals engineers watch: no import error, no strange traceback, no new dependency in the tree. The interpreter simply started, ran the hidden hook, and carried on.

There is also a practical trap in the response: the first check most people reach for, pip show agent-framework, starts Python — and therefore runs the stealer again. Do not investigate an affected environment by invoking the affected interpreter; check from a clean environment, or inspect the environment's files without starting its Python. In a .pth compromise, your diagnostic tools are part of the trigger surface.

None of this is exotic. The .pth mechanism is documented Python behaviour, and it exists for legitimate reasons. The lesson: your threat model for dependencies has to include code execution at install and interpreter-start time, not only at import time. If your controls assume a package is harmless until imported, this incident is the counterexample.

What the stealer collected — and the blast radius

The payload was a thorough credential harvester. It collected credential-like environment variables and secret-looking values from other processes' environments, and read credential files: up to 60 in version 1.26.1 and up to 80 in 1.26.2. The haul included Azure CLI configuration, .npmrc, pip.conf, .netrc, .git-credentials, Docker configuration, Hugging Face tokens, Azure DevOps agent credentials, and .env and JSON files in common application directories.

It also went after cloud identity directly: Azure DevOps OIDC tokens and Azure managed-identity tokens for twelve resources, plus instance metadata. Version 1.26.2 additionally requested GitHub Actions OIDC tokens in workflows that had id-token: write permission. That last detail is a sharp one: the id-token: write permission exists so a workflow can mint short-lived identity tokens, and the poisoned package tried to use that capability against the workflow itself. Short-lived tokens limit the window of misuse, but they do not prevent the theft — a token that lives for minutes is still usable for minutes, and automated exfiltration takes seconds.

Exfiltration was simple, and that simplicity is informative. The payload sent a single HTTPS POST of compressed, encoded JSON to a fixed webhook.site URL, with no fallback channel — no domain-generation algorithm, no multi-stage command and control, no rotating endpoints. One URL, one POST. That makes the attack easier to detect in retrospect — a webhook.site call from a build environment is conspicuous — but the attack did not need to be sophisticated to work. The hard part was getting the poisoned package published; once it was installed, the rest was a short script and a single request.

The measured impact, as analysed by Wiz, corrects both panic and complacency. Wiz analysed the 50 requests stored at the exfiltration endpoint: 4 were from the attacker, 29 were from sandboxes, scanners, and tests, and 17 represented 3 unique successful exfiltrations of victim data. Three successful exfiltrations is a small number — and three too many, because each one could carry cloud credentials, registry tokens, and identity tokens with real scope. The low count reflects the short window and the fast takedown, not an ineffective attack: a longer window, or a slower takedown, would have produced proportionally more.

The blast radius is not best measured in download counts or exfiltrated records. It is measured in the environments that installed the poisoned versions and then ran Python while credentials were present: developer machines with cloud CLI sessions, CI runners with OIDC permissions, build agents with registry credentials, and any container image built in that window that baked the package into its layers. If you cannot enumerate that set, you cannot bound the incident — which is why the response playbook starts with exposure, not with cleanup.

Why the usual defences would or would not have caught it

The wrong lesson from this incident is "pin your dependencies." Pinning, lockfiles, and hash verification are real controls that solve real problems — but they would not, on their own, have saved you here, and understanding exactly why is what lets you choose the controls that would.

Pinning and lockfiles. A pinned version and a lockfile protect against unexpected upgrades: you install the version you tested, not whatever is newest. But the poisoned releases were published as the next versions in the normal sequence — 1.26.1, then 1.26.2, after the safe 1.26.0 — so any workflow that installs the latest version, or updates its lockfile on a schedule, would have picked them up as ordinary updates. A lockfile pinned to 1.26.0 would have protected you only if your lockfile update had not yet run in the window — and only by luck of timing, not by design. Pinning is a control against drift, not against a malicious release.

Hash verification. Hash-checking verifies that the artifact you received matches the hash you recorded. It does not verify that the artifact is safe. The poisoned wheels were the artifacts as published; their hashes were the hashes of poisoned files. If your pipeline recorded hashes from the registry at install time, verification would have passed. Hash verification protects integrity in transit and against tampering after publication; it says nothing about what the publisher — or someone who compromised the publisher's pipeline — put into the artifact in the first place. Integrity is not provenance, and neither is safety.

Provenance and SLSA. Provenance records — the kind SLSA formalises — attest to how an artifact was built: source revision, build system, steps. They answer "did this artifact come from the build I trust?" — but their value depends entirely on the trustworthiness of the build itself. Here, the root cause is assessed by Wiz — not confirmed by Microsoft — as a compromise of a client certificate and private key belonging to Microsoft's Engineering System Release Pipeline (ESRP). An initial publish attempt from AWS was rejected by IP filtering before a second attempt from Microsoft-owned IP space succeeded; how the credentials were obtained is unknown. If the attacker could publish through the release pipeline itself, then a provenance attestation generated by that pipeline would attest to a poisoned build. Provenance raises the bar — an attacker who merely uploads a file cannot forge it — but it is not a defence against compromise of the pipeline that issues the attestation.

Private mirrors and curated registries. A private mirror that only syncs approved packages, or holds new versions for a delay before making them available, would have helped here — if the delay exceeded the exposure window. The poisoned versions were live for under an hour and pulled within about 55 minutes of the first publish. A mirror with a quarantine delay of a few hours, or one that only promotes versions after they have been scanned and observed, would have kept both releases out of your environments entirely. This is one of the few controls that would have stopped this attack cold: a poisoned release has to be live to be installed, and a fast takedown means a delayed mirror never sees it. The cost is real — you wait for new versions, and you maintain the mirror — but for production and CI environments, the trade is usually worth it.

Scanners. Scanners that check installed packages against known-bad lists — pip-audit, OSV-Scanner, and their peers — would have flagged the poisoned versions once the advisories were published. That is after the fact: the window between installation and detection is what determines whether credentials were stolen. A scanner run in CI on every build would have caught the package on the next build after the advisory landed; a nightly scanner would have caught it that night. Either way, scanning is detection, not prevention, and where the payload runs at interpreter start, detection after installation is already late for the credentials in that environment. Scanners are still worth running — they are how you find out you were exposed — but do not mistake them for a barrier.

OIDC and short-lived tokens. Short-lived tokens are the right design, and this incident shows both their value and their limit: a stolen Azure managed-identity token or GitHub Actions OIDC token expires quickly, bounding how long an attacker can use it. But "short-lived" is measured in minutes to an hour, and exfiltration plus automated use takes seconds. Short-lived tokens shrink the blast radius; they do not prevent the theft. The more important control in this family is scope: a token that can only do one narrow thing is worth far less to an attacker than a broad credential. Workflows with id-token: write were specifically targeted, which means the permission itself was part of the attack surface — grant it only to the workflows that need it, and scope the resulting cloud role as tightly as the job allows.

Credential scoping and separation. The deepest defence here is the least glamorous: do not put long-lived, broadly-scoped credentials where a build process can read them. A CI runner holding Azure CLI configuration, a Docker config with registry credentials, and a .netrc with repository access is one compromise away from handing all of them to any code that runs there — the stealer read up to 80 credential files precisely because environments accumulate them. Separating credentials by purpose, scoping each to the minimum it needs, and keeping long-lived secrets out of build and development environments is unglamorous work, and it is what determines whether a compromise like this one is a bad afternoon or a full cloud takeover. For more on the discipline of scoping and rotation, see our guide to secrets management at scale.

Network egress controls. The exfiltration was a single POST to a fixed webhook.site URL. Egress controls — an allowlist of destinations, or a proxy blocking known pastebin and webhook services — would have blocked it even after the payload ran. This is the control that most directly answers "the package was already installed and the payload already ran." It does not stop the theft from the local filesystem, but it stops the data leaving — in this incident, the difference between a compromised environment and a compromised cloud account. Egress controls are fiddly to maintain, which is why they are usually absent from developer machines and inconsistently applied in CI, but they are worth the friction in build environments, where the set of legitimate destinations is small and enumerable.

Head-to-head: the defences, compared

No single control above would have been enough. The table compares them on three questions: what it stops, what it costs, and what it misses.

DefenceWhat it stopsWhat it costsWhat it misses
Pinning + lockfilesUnexpected upgradesLockfile maintenance; delayed adoption of new versionsA malicious release published as the next version
Hash verificationTampering in transit or after publicationHash recording and verificationA poisoned artifact as published; says nothing about safety
Provenance / SLSAForged uploads and builds outside the trusted pipelineBuild-system integration; attestation verificationCompromise of the issuing pipeline itself
Private mirror + quarantine delayShort-lived poisoned releases, if the delay exceeds the exposure windowMirror maintenance; delayed new versionsA poisoned release that survives longer than the delay
Vulnerability scanningKnown-bad packages, once advisories existScanner integration; finding triageAnything installed before the advisory; detection is after the fact
OIDC and short-lived tokensLong-lived credential theft; bounds the misuse windowIdentity configuration per workflowTheft itself — a short-lived token is still usable
Credential scopingBroad blast radius from a single environment compromiseOngoing hygiene; per-service credentialsThe initial theft from a poorly-scoped environment
Egress controlsExfiltration to arbitrary endpointsAllowlist maintenance; frictionLocal credential theft
Ephemeral CI runnersPersistence of a compromise across buildsRunner provisioning; cold startsThe build that ran while the poisoned package was installed

Defence in depth — each layer stops a different failure Pin + lockfile — exact versions, no floating ranges Hash verification — wheel hashes checked at install Provenance — SLSA attestations, trusted publishers Private mirror — only reviewed packages enter Scanners — pip-audit · osv-scanner in CI Scoped credentials — short-lived OIDC, least privilege No single layer stops a trusted-publisher compromise; the stack does.

If you installed 1.26.1 or 1.26.2: the response playbook

If you think you may have installed either poisoned version, work the playbook in order — do not skip ahead to cleanup, and do not start by running diagnostic commands inside the affected environment.

1. Establish exposure before you touch anything. Determine whether the poisoned versions were installed anywhere: developer machines, CI runners, containers, and images built in the window. Check installation records, lockfiles, build logs, and image layers. Remember the trap: do not run pip show agent-framework or any other Python-invoking command inside the affected environment, because starting Python runs the stealer again — inspect the environment's files directly, or check from a clean environment. Look for the .pth files themselves — agent_framework_meta.pth and af_runtime_diag.pth in site-packages — and for the package version in installation metadata. If you cannot determine exposure from records, treat the environment as exposed. Uncertainty is not evidence of safety.

2. Assume credentials in an exposed environment are compromised. This is the step people resist, because rotation is expensive. The payload collected broadly — environment variables, credential files, cloud identity tokens, and instance metadata. If an exposed environment held credentials of any kind, assume they were harvested, including ones you think were not in use: the stealer read files, not just active sessions. Rotating a credential that was not stolen costs a few minutes. Leaving a stolen one in place costs an account takeover discovered weeks later.

3. Rotate, in order of blast radius. Start with cloud identity: Azure credentials and managed-identity assignments, Azure DevOps tokens, and GitHub Actions secrets or OIDC trust relationships for affected workflows. Then registry and repository credentials — Docker config, .npmrc, .netrc, .git-credentials — then service tokens such as Hugging Face, then application secrets found in .env and JSON files. Revoke rather than merely rotate where the provider allows it: revocation kills the stolen credential immediately, while rotation alone can leave the old value valid.

4. Rebuild from a clean environment. Do not clean an affected environment in place: remove the poisoned package, delete the .pth files, and rebuild from scratch — a fresh virtual environment, a fresh container image, a fresh CI runner. In-place cleanup leaves you guessing about what else the payload may have touched. Pin agent-framework to 1.26.0 or a later safe release in the rebuild, and verify the installed version from the clean environment.

5. Check for use of the stolen material. Review cloud audit logs for the exposure window and after: unexpected token use, new sessions, unfamiliar IP addresses, resource creation, role changes. If you find evidence of use, escalate to your cloud provider and treat it as an active intrusion. If you find nothing, record that: a clean audit log is evidence, and it matters for the post-incident review.

6. Scan everything, then keep scanning. Scan across your environments — pip-audit or OSV-Scanner against your lockfiles and installed packages — to find any other exposure, including transitive installs you did not know about:

# Example: check installed packages and lockfiles against known advisories
pip-audit
osv-scanner --lockfile requirements.txt
osv-scanner --lockfile poetry.lock

And when you pin the safe version, make the pin explicit and visible, so the next person to touch the dependency sees the reason:

# Example: pin the last safe release until a verified fix is published
# agent-framework 1.26.1 and 1.26.2 were compromised (PYSEC-2026-4388);
# 1.26.0 is the last safe release.
agent-framework==1.26.0

7. Write it down. Record the exposure window, the environments affected, what was rotated, and what the audit logs showed. The next incident will be a different package, and the record of this one is what lets you answer "are we exposed?" in minutes instead of hours.

Recommendation: the layered defence order

Build the layers in this order: each one assumes the ones before it and covers the gaps they leave.

First, get your build environments under control. Move CI and production builds behind a private mirror with a quarantine delay, on ephemeral runners destroyed after each job. This is the prevention layer for exactly this class of attack, and the control that would have stopped this incident outright. For the pipeline design that surrounds it, see our guide to secure CI/CD pipelines.

Second, verify what you install. Enforce lockfiles and hash verification in CI, and verify provenance attestations where the publisher provides them. These are cheap, they stop real attacks, and they record exactly what was installed — which is what makes the exposure question answerable. They will not stop a compromised pipeline on their own, but without them you cannot tell what you installed, and every later step gets harder.

Third, shrink what a compromise can steal. Scope credentials to the minimum each job needs, prefer short-lived OIDC tokens over long-lived secrets, and keep long-lived credentials out of build and development environments. Remove id-token: write from every workflow that does not need it. This layer is unglamorous and ongoing, and it decides whether a future incident is a bad afternoon or a breach.

Fourth, control egress and detect fast. Apply egress controls in CI and build environments, and scan on every build and on a schedule. Egress controls stop the data leaving; scanning tells you that you were exposed. Neither prevents the install, and both are worth having precisely because prevention will fail one day.

Fifth, practise the response. Keep the playbook above somewhere your team can find it at 21:30 UTC on a Monday night, and make sure someone can answer "which environments installed this version?" without starting the affected interpreter. The difference between a three-victim incident and a three-hundred-victim incident is often just the speed of the first hour.

Every control in the table has a miss, and the misses are different — that is the whole point. A compromised publisher defeats pinning, provenance, and hashing, but not a quarantine delay. A long-lived poisoned release defeats a quarantine delay, but not scanning and egress controls. You do not layer defences because you are paranoid. You layer them because each one fails in a different way.

Did 1.26.1 or 1.26.2 touch your environment? What is your exposure? check first, rotate second Installed 1.26.1/2 in the Nov 17 window Unsure check lockfiles + logs Clean 1.26.0 stay pinned Rotate + revoke all creds + OIDC tokens Rebuild clean fresh env, no reuse Add the layers scanners + mirror Assume compromise until the logs say otherwise — then prove it.

Architecture Decision

Decision: Adopt a layered supply-chain defence for Python environments: private mirror with quarantine delay and ephemeral CI runners first, then lockfile and provenance verification, then credential scoping with short-lived tokens, then egress controls and scanning — rather than relying on any single control or treating pinning as the defence.

Context: The November 17, 2026 compromise of agent-framework 1.26.1 and 1.26.2 showed that a poisoned release can be published through a release pipeline, execute at interpreter start via a .pth file without any import, and harvest cloud credentials within a sub-one-hour window. Pinning alone would not have stopped it, and any single control has a known miss.

Options considered: Pinning and lockfiles alone; hash verification and provenance alone; scanning alone; a private mirror with a quarantine delay; and the layered approach adopted here.

Why this one: The layered approach is the only option where the failure of any one control is covered by another. The private mirror with a quarantine delay is the one control that would have stopped this incident outright, exploiting the attacker's constraint that a poisoned release must be live to be installed. The remaining layers cover the cases the mirror does not: a release that survives longer than the delay, a compromise of the mirror's own sources, and a payload that executes before any check runs. The order reflects cost-effectiveness — the mirror and ephemeral runners first because they prevent the most, credential scoping next because it bounds the worst case, and scanning last because detection is necessary but not sufficient.

What it costs you: A private mirror to maintain and a delay before new versions reach your builds; ephemeral runners slower to start than persistent ones; ongoing credential hygiene, including scoping tokens per workflow and removing id-token: write where it is not needed; egress allowlists developers will occasionally find restrictive; and scanning findings someone has to triage. None is large on its own, and all are smaller than rotating a cloud estate after a compromise.

When to reverse it: If your environment never runs untrusted code — no third-party packages, no CI that installs dependencies, no developer machines with cloud credentials — the full stack is overkill, and simpler controls would do. Revisit the quarantine delay if it starts blocking security patches: a delay that keeps a poisoned release out but also keeps a patched release out should be shortened or made bypassable for verified security updates. Revisit the layering itself if a future incident shows a gap none of the layers cover.

When NOT to rely on each defence — and when not to overreact

Each defence in this article has a failure mode. Do not rely on pinning to protect you from a malicious release — it protects you from drift, and a poisoned version is not drift. Do not rely on hash verification to tell you a package is safe — it tells you the package is unchanged, and a poisoned package is unchanged from its poisoned state. Do not rely on provenance when the pipeline that issues the attestation is the thing that was compromised. Do not rely on a quarantine delay against a poisoned release that stays live for weeks; the delay only helps against short windows. Do not rely on scanning to prevent an install — it detects after the fact, and here after the fact was already late. Do not rely on short-lived tokens to prevent theft — they bound the misuse window, and the theft itself happens in seconds.

There is also a limit on the other side: do not overreact. This was a serious incident, and a contained one — two versions, under an hour each, pulled the same evening, with three confirmed successful exfiltrations. The right response is not to stop using PyPI, to vendor every dependency, or to ban the Microsoft Agent Framework. Vendoring everything trades one risk for another, and banning a package because its publisher was attacked once is superstition, not security. The second Microsoft-related PyPI compromise of 2026 is a reason to harden the pipeline, not to abandon the ecosystem.

What deserves a durable response is the set of assumptions this incident broke: a package is not safe because it comes from a trusted publisher; it is not inert because nothing imports it; a version number is not a safety signal; a lockfile is not a security control on its own; and a build environment is not a trusted place — it is a place where arbitrary code runs, often with credentials nearby. Design your defences for the environment you actually have, where the next poisoned release is a matter of when, not if.

For the broader discipline this incident sits inside — how to think about the software you did not write — see our guide to supply-chain security, SBOMs, and signing. The tools exist. The layers are known. The work is doing them in order, before the next short window opens.

Why This Matters

Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.

Trade-offs to Consider

Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.

When NOT to Use This

Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.

Decision Framework

Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.

Share this articleShare on XShare on LinkedIn

Keep the decision frameworks coming

One practical architecture guide a week — patterns, trade-offs, and when not to use them. No spam, unsubscribe anytime.