Breach Value Calculator

Malicious agent-framework 1.26.1 and 1.26.2 on PyPI: What to Rotate

GitHub says agent-framework 1.26.1 and 1.26.2 on PyPI ran a credential stealer at Python start-up. How to check, and which secrets to rotate.

Two releases of agent-framework, the Python package for Microsoft Agent Framework, were malicious: versions 1.26.1 and 1.26.2 on PyPI. GitHub's advisory says they carried a credential stealer that ran every time Python started, whether or not the package was imported. Both are gone from PyPI. If either was installed anywhere, rebuild that environment and rotate every secret it could reach.

Sources read 21 November 2026.

To check an environment, run pip show agent-framework: version 1.26.1 or 1.26.2 means act now, while 1.26.0 or earlier is not affected, per the advisory. The advisory also names the start-up files the two releases added, agent_framework_meta.pth (1.26.1) and af_runtime_diag.pth (1.26.2), which can be searched for in site-packages.

What happened to agent-framework on PyPI?

The GitHub Advisory Database published GHSA-764m-3ppc-5m73, titled "Malicious code in agent-framework (PyPI)", at 00:31 UTC on 18 November 2026. It is filed as malware, not as an ordinary vulnerability, and carries no CVE number.

According to the advisory:

  • Which versions: 1.26.1 and 1.26.2, which it describes as compromised releases of a legitimate Microsoft package.
  • What they did: added a credential stealer that ran at every Python interpreter start through a .pth start-up file, even if no code imported the package.
  • What it collected: environment variables, credential files, and cloud, CI and managed-identity tokens, sent to an external webhook.
  • What is safe: version 1.26.0 and earlier are not affected.
  • Status: both malicious releases have been removed from PyPI. There is no "patched" version; the fix is to not run the bad ones.
  • Weakness class: CWE-506, Embedded Malicious Code.

The advisory credits the finding to the OpenSSF malicious-packages project, with analysis from the researcher kam193 and Amazon Inspector. It groups the two releases under one campaign name, 2026-11-compr-agent-framework, and lists credential exfiltration, obfuscation and abuse of .pth start-up files among its reasons for the malicious label.

The advisory does not say how the two versions came to be published under the project's name, and that question stays open here. We found no statement from Microsoft on its own site as of 21 November 2026.

What is agent-framework?

On its PyPI page, agent-framework describes itself as "Microsoft Agent Framework for building AI Agents with Python." The listed author is Microsoft, and the source code lives in the microsoft/agent-framework repository on GitHub.

That matters for who is exposed. An agent framework sits close to the most valuable keys a team holds: model provider API keys, cloud identities for the tools an agent calls, and the CI credentials that build and deploy it.

When the page was read on 21 November 2026, the release history ran 1.24.0 (30 October), 1.25.0 (7 November) and 1.26.0 (12 November). Neither 1.26.1 nor 1.26.2 appears, and 1.26.0 is shown as the current release.

Which installs of agent-framework are affected?

The window opens on 17 November 2026: the advisory says 1.26.1 was published at 20:35 UTC that day and 1.26.2 at 21:08 UTC. It says both have since been removed from PyPI but gives no removal time, so the end of the window is not public; the advisory itself went up at 00:31 UTC on 18 November.

Anyone who installed agent-framework 1.26.1 or 1.26.2, on any machine. That includes:

  • Developer laptops where someone ran pip install -U agent-framework or refreshed dependencies while either version was live.
  • CI runners and build agents that resolved the newest version during the window. A pipeline with an unpinned or loosely pinned requirement (for example agent-framework>=1.25) would have picked it up without anyone choosing it.
  • Container images built during the window, and every container started from them since.
  • Notebooks, shared Python environments and agent hosts that installed or upgraded packages at that time.

The start-up behaviour widens this. Because the code ran whenever Python started in that environment, any Python process there could trigger it: a test run, a linter, an unrelated script.

If your lock files and images only ever held 1.26.0 or earlier, the advisory says you are not affected.

How do you clean up after agent-framework 1.26.1 or 1.26.2?

  1. Find it. Search lock files and dependency manifests for agent-framework==1.26.1 or 1.26.2: requirements*.txt, poetry.lock, uv.lock, Pipfile.lock, pdm.lock. On live machines and in images, pip show agent-framework prints the installed version. Check CI logs from the window for either version string, and check private package mirrors or proxies that may have cached them.
  2. Pin to a known-good version. Set agent-framework==1.26.0 (or earlier) until a later release is published and checked. A pin with hashes stops a silent swap.
  3. Rebuild, don't clean. Removing the package with pip uninstall may not remove everything a payload left behind. Delete the affected virtual environment, container image or runner and build a fresh one from a pinned lock file.
  4. Rotate every secret the machine could reach. The advisory tells anyone who installed either version to rotate reachable credentials, including CI and GitHub Actions secrets. In practice that list covers: - cloud access keys and service principal secrets (AWS, Azure, Google Cloud); - CI tokens and repository secrets, including GitHub Actions secrets and personal access tokens on developer machines; - API keys for third-party services in .env files or environment variables; - model provider keys (OpenAI, Anthropic, Azure OpenAI and others); - package-publishing tokens for PyPI, npm or other registries, so the compromise cannot spread into your own packages; - SSH keys and database passwords stored on the host.
  5. Check how those secrets were used. Look at cloud audit logs, model provider usage dashboards and CI audit logs for activity from unfamiliar IP addresses or at unusual times since the install.
  6. Tell downstream users if you publish software or images that bundled either version, and say which builds to replace.

The AI coding assistants guide covers keeping secrets out of the places tools can read, and the CI/CD for AI applications guide covers pinning and protected deploy credentials.

Why did the stealer run without an import?

Python runs certain lines in .pth files automatically. The site module documentation says this module "is automatically imported during initialization", and that in a .pth file, "lines starting with import (followed by space or tab) are executed with exec()."

The same page adds that these executable lines "are always run at Python startup (unless -S is given to disable the site.py module entirely), regardless of whether a particular module is actually going to be used."

So a package only needs to drop one small file into site-packages at install time. From then on, every interpreter in that environment runs it. Nobody has to write import agent_framework.

Going deeper: for security and IT teams

How it works. A wheel can ship arbitrary files into site-packages, and the site module scans that directory at start-up for name.pth files, processed in alphabetical order. Path lines extend sys.path; lines beginning with import go to exec(). That gives an installed distribution code execution in every interpreter launched from that prefix, before user code, with no import and no install hook needed at run time. This is a long-standing, documented feature kept for backward compatibility, not a bug in pip or PyPI. The Python docs now mark it for retirement: from Python 3.15, .pth lines starting with import "are deprecated", they "will be silently ignored in Python 3.18 and 3.19", and Python 3.20 will warn about them. Until your fleet runs those versions, treat any new .pth file as executable code.

Threat model. The attacker needs the ability to publish a new version under a trusted project name. They get code execution wherever the newest version resolves: developer laptops, CI runners, and production agent hosts. The payoff is the credential set those hosts hold. For an AI agent project that usually means model provider keys plus cloud identities with real permissions. Per the advisory, the payload also took managed-identity tokens, so a stolen credential may be a short-lived cloud token rather than a static key. Short-lived tokens still work until they expire, so revoke sessions as well as rotating secrets.

In practice: CI is where this lands. The wfx-loot campaign on 10 and 11 November 2026 went after the same prize by a different route. Aikido Security's write-up counted pull requests opened in 61,764 repositories and at least 1,835 repositories where the payload ran and credentials were taken. Different entry point, same target: whatever secrets a build job can see.

Controls with specifics.

  • Pin with hashes. pip install --require-hashes -r requirements.txt (or uv and Poetry lock files with hashes) refuses any artefact whose digest is not already recorded. A new malicious version cannot slip in under a range specifier.
  • Delay new releases. Point CI at an internal mirror or proxy that only serves versions after a holding period and a scan. Both of these releases were pulled from PyPI; a holding period gives detection and removal time to happen before your builds see a new version.
  • Scope CI secrets. Give dependency-install jobs no deploy credentials, and pass secrets only to the job and environment that needs them.
  • Use Trusted Publishing for your own packages. PyPI's Trusted Publishers documentation describes publishing from CI through OpenID Connect instead of a stored API token. Its internals page says that when the CI identity matches a Trusted Publisher, PyPI issues a short-lived (15 minute) API token, so a leaked token has little shelf life. PyPI's attestations security model adds signed provenance tied to that publisher identity, which lets consumers check where a file was built.

Detection and evidence.

  • Inventory .pth files across site-packages in images and runners, and alert on any new one that contains an import line. Most legitimate ones are path-only.
  • Watch for Python processes making outbound connections to webhook or paste services from build agents that normally only talk to package indexes and your cloud.
  • In cloud audit logs (AWS CloudTrail, Azure Activity Log and Entra sign-in logs, Google Cloud Audit Logs), look for use of rotated or CI-held credentials from addresses outside your runner ranges since the install.
  • Compare the CI run log for the window against the lock file. A version you never pinned showing up in an install step is the finding.

What to verify or ask.

  • Which builds between the release of 1.26.0 and the advisory resolved agent-framework, and to which version?
  • Does any pipeline install from PyPI directly rather than through a mirror with a holding period?
  • Which secrets were present as environment variables on runners that install third-party packages?
  • For each AI framework you depend on, does its PyPI page show provenance or attestations for the files you install?

Key takeaways

  • agent-framework 1.26.1 and 1.26.2 on PyPI carried a credential stealer; 1.26.0 and earlier are not affected, per GitHub's advisory.
  • The code ran at Python start-up through a .pth file, so installing it was enough.
  • Check lock files, images, runners and CI logs; rebuild rather than uninstall.
  • Rotate cloud keys, CI tokens, API keys, model provider keys and publishing tokens from any machine that had either version.
  • Pin with hashes, delay new releases through a mirror, and keep deploy secrets away from install steps.

Sources

Spotted a mistake? Report a correction.