Microsoft Agent Framework PyPI Compromise: What Happened

Microsoft Agent Framework PyPI Compromise: What Happened
Last reviewed 21 November 2026. Microsoft Agent Framework’s legitimate agent-framework package on PyPI was compromised on 17 November. Malicious versions 1.26.1 and 1.26.2 used Python startup hooks to steal cloud and CI/CD credentials; 1.26.0 was the last known clean release. This article reconstructs the incident and explains the enterprise response.

At 20:35 UTC, an ordinary build instruction changed meaning.

python -m pip install agent-framework

The command did not point to a misspelled project. It did not fetch a package from an unfamiliar domain. It asked the Python Package Index for agent-framework, the legitimate package name used by Microsoft Agent Framework.

The installer found version 1.26.1. The name was right. The metadata looked right. The package still pulled in the real agent-framework-core==1.26.0, so the software a developer expected would continue to arrive and work.

It also installed a credential stealer.

The malicious code was not waiting for an application to create an agent. It did not need a model to follow a poisoned prompt. It did not need the framework to be imported at all. A small Python startup hook meant that the next interpreter process could run it automatically.

At 21:08 UTC, 33 minutes after the first poisoned wheel was published, version 1.26.2 appeared. The malicious files had new names. The collection logic had expanded. According to the public GitHub advisory, it now explicitly pursued GitHub Actions identity tokens and runner paths. [1]

By 21:35 UTC, a public issue on Microsoft’s repository reported that both versions had been removed and the package feed had returned to the last known clean release, 1.26.0. A Microsoft maintainer acknowledged the compromise and said the team was investigating. [2]

Less than an hour had passed. That sounds brief until the clock belongs to a build system.

20:35 UTCMalicious 1.26.1 is uploaded as a wheel.
21:08 UTCMalicious 1.26.2 follows with renamed files and expanded targets.
21:35 UTCThe public incident thread reports both releases removed; clean 1.26.0 is current again.
The package was official. The release was not. That distinction is becoming one of the most important controls in enterprise AI.

Microsoft Agent Framework PyPI compromise: the answer in six facts

  • Affected package: the legitimate agent-framework project on PyPI—not a typosquat.
  • Malicious versions: 1.26.1 and 1.26.2, both published on 17 November 2026.
  • Last known clean version: 1.26.0 and earlier, according to the GitHub malware advisory.
  • Execution: a .pth startup hook ran when Python started, even if the framework was never imported.
  • Targets: environment secrets, credential files, cloud identity endpoints and CI/CD tokens.
  • Response: remove the startup hooks before invoking Python, rebuild affected environments, purge caches and rotate every credential the host could reach.

The parcel arrived through the front door

Software supply-chain stories are often told as cases of mistaken identity. An attacker publishes a package whose name differs from a popular library by one character. A developer mistypes a command. The wrong parcel reaches the loading dock because its label resembles the right one.

This incident was different. The malicious artifacts appeared under the legitimate PyPI project. The current PyPI record identifies the package as Microsoft Agent Framework, lists Microsoft-associated maintainers and marks 1.26.1 and 1.26.2 as quarantined releases. [3]

That makes the enterprise failure mode more uncomfortable. A package allow-list would see an approved name. A dependency scanner might see the expected project. A developer reviewing the public source repository would not find the payload, because the injected code was in the distributed wheel rather than the repository’s reviewed source.

The first poisoned wheel was particularly economical. Compared with clean 1.26.0, the initial public analysis found three relevant file changes: a new agent_framework_meta.pth, a new telemetry-looking helper and a small modification to an initializer that started it inside a silent error handler. The rest of the package continued to resemble the clean release.

This is camouflage by continuity. The application does not need to crash. Its normal features do not need to disappear. The malicious parcel can contain the product the buyer ordered and something else beneath it.

What this was not

This was not evidence of an AI agent escaping its instructions. The compromise occurred in the developer package supply chain. The framework’s association with agents matters because of where such software is installed and what those environments can reach—not because a model autonomously designed the attack.

Python opened the parcel before the application did

The most important technical detail is only a few characters long: .pth.

Python’s site initialization processes path-configuration files found in site-package directories. Lines beginning with import can execute at interpreter startup. The official Python documentation warns that executable lines in these files run at every startup, whether or not a particular module will be used. [4]

That feature normally supports environment configuration. In the malicious 1.26.1 wheel, the startup file imported agent_framework_meta. Version 1.26.2 renamed the mechanism to af_runtime_diag.pth and af_runtime_diag.py. In both cases, starting Python was enough to cross the execution boundary.

Expected mental model
install package → import package → package code runs

What the startup hook changed
install package → start almost any Python process → payload runs

This is why “the application never imported Agent Framework” would not clear an environment. Package installation places files into a shared interpreter environment. Once the hook is present, a test runner, command-line tool, IDE language server, container entrypoint or even a later package-management command may start Python and process it.

The public incident thread made the remediation sequence unusually consequential: beginning with pip uninstall could itself start Python and trigger the hook one more time. The recommended order was to neutralize or remove the startup files first, then reinstall a known-clean, hash-pinned version, purge caches and rebuild affected images.

A dependency is not inert data. Installing it is a decision to place executable material inside the runtime’s trust boundary. The package manager may be the delivery vehicle, but the operating fact is arbitrary code execution.

Which Microsoft Agent Framework versions were compromised?

If version 1.26.1 had been the only upload, the story could be framed as one poisoned artifact slipping through. Version 1.26.2 makes that framing harder.

The second wheel arrived after the first had drawn attention. Its malicious files were renamed, the clean initializer was restored and the startup file became the sole trigger. The advisory says the collector added GitHub Actions OIDC-related environment variables and runner paths, and increased the number of files it would capture.

The safe conclusion is narrow. Someone retained enough publication authority to place a second artifact under the same project name. The public evidence does not, by itself, establish exactly how that authority was obtained. A stolen long-lived token is one possibility; a compromised account or release path is another. Microsoft had not published a complete root-cause report at the time this article was prepared.

That uncertainty should not be filled with a confident story. It should become an audit question:

Who can publish this package, from which workflow, with which identity, after which approval—and can the registry prove that chain?

Traditional package trust often ends at the project name. Modern supply-chain trust has to continue through the artifact, builder, source revision, workflow and authorization event.

The thief was looking for doors, not files

The payload collected basic host information, then searched environment-variable names associated with tokens, passwords, cloud providers, GitHub, Hugging Face, OpenAI, package managers and CI systems. It examined credential files, attempted to read other processes’ environments on Linux and queried cloud identity endpoints where available. The second version added more direct handling for GitHub Actions tokens. The collected material was compressed, encoded and posted to a single remote endpoint documented in the advisory. [1]

The list reveals the economic logic of the attack. The developer machine is useful. A build runner can be better.

A laptop may hold source access and personal cloud credentials. A CI job may temporarily hold deployment authority, package-publishing permission, artifact-cache access and an identity that production systems trust. GitHub’s documentation explains that Actions workflows can exchange an OIDC identity for short-lived cloud access rather than storing a permanent secret. [5] Short-lived credentials reduce the value of a credential after it expires. They do not make a live, overprivileged token harmless during the job that mints it.

Agent-development environments are attractive because agents are integration-heavy by design. A useful enterprise agent may connect to a model provider, source repository, vector store, customer database, browser, ticketing system and cloud runtime. Its build process can therefore sit near many credentials even when the final application follows least privilege.

The security boundary is not simply the agent’s tool list. It begins earlier—with the packages used to build the agent and the machine that resolves them.

Why a short registry window can be a long enterprise incident

A malicious release does not need to remain current for days. It needs to be selected once by an environment whose output persists.

Consider fresh, unpinned dependency resolutions arriving approximately as a Poisson process. If an organization performs them at rate λ per hour and a malicious release remains selectable for t hours, the probability of at least one resolution during that interval is:

P(at least one resolution) = 1 − e−λt

Use five fresh resolutions per hour and an illustrative 55-minute exposure window. The probability of at least one resolution is about 98.98%. This is not an estimate of infections from the Microsoft incident. It is a demonstration of how build frequency converts minutes on a registry into a near certainty inside a sufficiently active, unpinned estate.

The durable footprint is wider than the download event. A wheel can be copied into an internal mirror. A container layer can be promoted. A CI cache can outlive the job. A developer image can be cloned. A lockfile generated during the window can make the malicious version reproducible with perfect consistency.

That last case is important. Reproducibility answers “can the same artifact be installed again?” It does not answer “was that artifact legitimate?” A precisely locked compromise remains a compromise.

Official identity, integrity and provenance are different claims

The language around package security often compresses several questions into one word: trusted.

ClaimQuestion answeredWhat it does not prove
IdentityDid the artifact appear under the expected registry project?That the publisher was authorized for this release.
IntegrityDoes the downloaded file match a known hash?That the known hash belongs to reviewed, safe code.
ProvenanceWhich builder, workflow and source produced the artifact?That the source or workflow itself was benign.
AuthorizationWas that workflow permitted to publish this version?That runtime behaviour was safe.
BehaviourWhat does the artifact actually do when installed and run?That every future build will behave identically.

PyPI’s current page for clean Agent Framework 1.26.0 says its files have no provenance metadata and were not uploaded using Trusted Publishing. That fact does not make 1.26.0 malicious; the registry and advisory identify it as the last known clean release. It means a consumer cannot use PyPI’s attestation mechanism to bind that artifact to a particular trusted publishing workflow. [3]

PyPI’s Trusted Publishing uses OpenID Connect so an approved CI configuration can exchange a short-lived identity token for a project-scoped upload token. PyPI documents that the minted token lasts 15 minutes, avoiding a manually created publishing credential that remains useful until someone notices and revokes it. [6]

This is a meaningful control, not a magic seal. If an attacker controls the trusted repository, workflow or CI identity, OIDC can faithfully attest to a compromised process. Provenance makes the chain inspectable. Policy still has to decide which chains are acceptable, and review still has to decide whether the source is safe.

A blue check beside a package name says who owns the shelf. Provenance says which factory filled the box.

Pinning would have helped. A version number alone was not enough

An environment locked to 1.26.0 would not have selected 1.26.1 or 1.26.2 automatically. That is already valuable. But secure installation needs both a version and a locally approved artifact hash.

Pip’s official guidance recommends hash-checking mode with --require-hashes and exact pins. Every requirement and dependency must carry an allowed hash; an unexpected artifact fails installation. The documentation also makes an important distinction: a hash supplied by the remote index protects against download corruption, but it is not a useful guard against a registry-side tampering event because the attacker-controlled artifact can arrive with its own remote hash. [7]

The approval process therefore matters. A team must obtain the hash from a release it has reviewed or from a trusted internal promotion pipeline—not copy it blindly from whatever the registry serves today.

agent-framework==1.26.0 \
  –hash=sha256:14267ec8e6929c139015f8ec918adc638a71c7656901413426bb30ab199b6d71

The hash above is the clean 1.26.0 wheel hash published in the incident record. It is shown as an example of artifact-level pinning, not as a universal requirements line: platform variants and dependency trees need their own reviewed hashes.

What to do if agent-framework 1.26.1 or 1.26.2 was installed

Removing a poisoned package stops future execution only after its startup mechanism is neutralized. It does not recall credentials already sent away. Affected environments must be treated as exposed.

01 · Stop
Neutralize startup hooks

Do not begin with a Python-based command on an affected environment. Follow the incident’s validated order for removing the known hooks.

02 · Scope
Find every resolution

Search lockfiles, installation reports, container layers, runner logs, caches and internal mirrors for both versions and their wheel hashes.

03 · Rebuild
Replace, do not merely clean

Rebuild images and virtual environments from a known-clean dependency set. Purge promoted artifacts and caches that can restore the wheel.

04 · Rotate
Assume reachable secrets escaped

Revoke long-lived keys and review short-lived identity use, cloud activity, repository access, cache writes and package publication.

05 · Hunt
Use behavior and indicators

Look for the documented filenames, wheel hashes, outbound endpoint, user agents, process-environment reads and identity-endpoint requests.

06 · Preserve
Keep the evidence

Record the exact artifact, host, job, credentials present and downstream outputs before ephemeral systems and logs disappear.

An SBOM helps answer which component was intended to be present. For this class of incident, an organization also needs an artifact ledger: exact filename and hash, resolver time, source registry or mirror, build job, resulting image digest and deployment destination. Without that chain, “we use Agent Framework” is too broad and “we pinned dependencies” may be too late.

The controls should form a queue, not a checklist

No single defence covers the whole route. The useful design is a sequence in which an artifact cannot move closer to production without accumulating stronger evidence.

ControlWhat it catchesWhere it can still fail
Exact version pinUnexpected newer releasesA pinned version can itself be malicious.
Locally approved hashesArtifact substitutionA reviewer can approve the wrong artifact.
Registry provenanceArtifacts from an unexpected builder or workflowThe attested workflow can be compromised.
Internal mirror quarantineBrand-new public releases entering immediatelyDelay is not code review; urgent bypasses weaken it.
Static and sandbox analysisKnown hooks, suspicious network or credential accessConditional and delayed behavior can evade observation.
Ephemeral, least-privileged runnersPersistence and blast radiusLive job credentials may still be stolen.
Egress policyUnexpected exfiltration destinationsAllowed services can become covert channels.
Artifact-to-deployment ledgerFast exposure scopingIt detects lineage, not malicious intent.

A sensible enterprise path is public registry → quarantine mirror → provenance policy → review and analysis → hash-pinned promotion → isolated build → signed internal artifact → deployment ledger. Not every dependency needs a week of manual inspection. Every dependency does need a policy proportional to the authority of the environment that will execute it.

The same lineage problem exists in AI data

The incident belongs to software security, but its central distinction extends to the rest of an AI system.

A model file can have the expected name without proving which training run produced it. A dataset can come from the expected vendor without proving which collection protocol, consent state or transformation created a row. An evaluation score can arrive in the official spreadsheet without proving which model build, prompt version and test split generated it.

Enterprise AI needs lineage at four layers: code, models, data and evaluation. Each layer needs an answer to the same questions: what exact artifact is this, where did it come from, which approved process produced it, what changed and where was it used?

This is closely related to the discipline behind sealed evaluation data. A benchmark name is not enough if its test set has leaked. A package name is not enough if its build path has been bypassed. Trust comes from the controlled chain, not the familiar label at the end.

The box on the loading dock

Return to the build at 20:35 UTC.

The package manager did what it was asked to do. It resolved the latest artifact under the requested name. The framework still worked. The malicious code was small, quiet and positioned to run before the application made its first meaningful decision.

Nothing in that moment required an employee to click a suspicious attachment. Nothing required a typo. Nothing required the AI agent to behave badly. The enterprise trusted the correct name at the wrong layer.

The response is not to abandon public packages or freeze every dependency indefinitely. It is to stop asking one signal—an official registry identity—to carry five different kinds of trust.

Names identify shelves. Hashes identify files. Provenance identifies build paths. Authorization decides which paths may publish. Runtime controls limit what the artifact can reach. Deployment records show where it went.

The next poisoned release may remain public for five minutes or five days. Its duration will matter less than whether one automated build is allowed to turn “latest” into “production” without leaving a verifiable trail.

The parcel can be official.

The enterprise still has to prove who packed it.

Microsoft Agent Framework PyPI compromise: frequently asked questions

Was Microsoft’s official Agent Framework package compromised?

Yes. The malicious artifacts appeared under the legitimate agent-framework project on PyPI. This was not a similarly named typosquatting package. The injected payload was present in distributed wheels but not in the corresponding public source repository.

Which agent-framework versions were malicious?

Versions 1.26.1 and 1.26.2 were malicious and are quarantined. The GitHub advisory identifies 1.26.0 and earlier as unaffected by these releases. Organizations should still verify exact wheel hashes and inspect internal caches rather than relying only on a version label.

How did the malware run without importing Agent Framework?

Each poisoned wheel installed an executable .pth file in the Python environment. Python processes these path-configuration files during normal site initialization, so the hook could execute whenever an interpreter started—even when application code never imported agent_framework.

Is uninstalling the package enough?

No. Starting pip could process the malicious startup hook once more, and removing files cannot revoke credentials already exposed. The public incident guidance says to neutralize the known hooks first, rebuild the environment, purge caches, rotate reachable long-lived secrets and review cloud, repository and CI activity.

How can an enterprise prevent the same failure?

Use exact version and locally approved hash pins, quarantine new public packages before promotion, require verifiable publishing provenance, isolate build runners, keep CI identities short-lived and narrowly scoped, restrict egress and record the exact artifact hash that produced every deployed image. No single control proves a package safe; the controls have to form a chain.

References and incident notes

  1. GitHub Advisory Database, GHSA-764m-3ppc-5m73, published 18 November 2026. Primary consolidated record for affected versions, upload times, startup behavior, collected credentials, exfiltration method, wheel hashes and remediation scope.
  2. Microsoft Agent Framework issue #10411, opened 17 November 2026. Public artifact comparison, timeline, indicators, response sequence and acknowledgement from a repository maintainer. The initial-access explanation remains an inference, not a published root-cause finding.
  3. PyPI project record for agent-framework. Registry identity, quarantine labels, clean 1.26.0 files and the absence of published provenance for the current release.
  4. Python documentation, the site module and path-configuration files. Startup processing and executable import lines in .pth files.
  5. GitHub documentation, OpenID Connect in GitHub Actions. How workflows exchange identity for short-lived cloud credentials.
  6. PyPI documentation, Publishing with a Trusted Publisher. OIDC trust configuration, 15-minute project-scoped upload tokens and the security difference from long-lived API tokens.
  7. Pip documentation, Secure installs and hash-checking mode. Exact pins, locally supplied hashes, all-dependency enforcement and the limitation of hashes supplied by a remote index.
Was this article helpful? No ratings yet