Table of contents

Microsoft agent-framework on PyPI: .pth hook steals Azure and CI credentials

Agent Framework Compromised

On November 17, 2026, two malicious versions of Microsoft’s agent-framework Python package were published to PyPI: 1.26.1 at 20:35 UTC and 1.26.2 at 21:08 UTC. The package as a whole has roughly 196,000 downloads a month; the figure covers all versions, not the two malicious releases. Both versions add a credential stealer that executes automatically during normal Python startup, without requiring the application to explicitly import the package. It collects secrets from the environment, credential files and other processes, requests Azure managed-identity and CI/CD OIDC tokens, and sends everything to a webhook[.]site URL. Both versions have since been removed from PyPI; the previous release, 1.26.0, does not contain this code.

What changed in the package

Each malicious wheel adds a one-line .pth file and a Python module that collects and uploads the data. The two versions differ in where that code lives and in how much it targets:

1.26.11.26.2
Startup hookagent_framework_meta.pthaf_runtime_diag.pth
Collectoragent_framework_meta/_telemetry.py, started from a block added to agent_framework_meta/__init__.pyaf_runtime_diag.py, a separate top-level module
GitHub Actions OIDCNoYes
User-Agentaf-runtime-diagnostics/1runtime-diagnostics/1

The second release, published 33 minutes after the first, leaves the package’s own code untouched. agent_framework_meta/__init__.py in 1.26.2 is byte-identical to the 1.26.0 file, and the collector sits in a new top-level module, so comparing the agent_framework_meta package against the previous release shows no change.

The second release retains the same collection mechanism but expands its targets, particularly in GitHub Actions environments. It adds four environment keywords (ACTIONS, OIDC, RUNNER, ARM_), includes ACTIONS_ID_TOKEN in the process-environment filter, introduces GitHub Actions OIDC token requests, adds paths under /home/runner/, and raises the file collection limit from 60 to 80. It also removes one Azure DevOps path, /agent/_work/*/.credentials.

How it executes

During normal Python startup, the site module processes .pth files in recognized site-packages directories and executes lines beginning with import. Each wheel’s .pth file contains a single such line:

import agent_framework_meta

Figure 1: The contents of agent_framework_meta.pth in 1.26.1. In 1.26.2 the line is import af_runtime_diag.

As a result, the collector runs automatically when a Python interpreter starts normally in an environment where the malicious package is installed, without requiring the application to import the package. In 1.26.1 the import reaches a block appended to __init__.py:

# Lightweight runtime diagnostics hook.
try:
    from . import _telemetry as _telemetry
    _telemetry._start()
except Exception:
    pass

Figure 2: The block added to agent_framework_meta/__init__.py in 1.26.1. In 1.26.2, af_runtime_diag.py calls _start() on its last line.

_start() exits early if the environment variable _AF_TEL is already set; otherwise it sets _AF_TEL=1, which child processes inherit, so the collector runs once per process tree. It then forks, and the child calls os.setsid() to detach, runs the collector and exits, while the original process carries on. Without fork, it uses a background thread. All errors are silently ignored.

What it collects

The collector gathers the hostname, user name, working directory and command-line arguments, then copies every environment variable whose name contains a secret-related keyword (31 keywords in 1.26.1, such as TOKEN, SECRET, PASSWORD, KEY, AZURE, AWS and GITHUB). It applies a similar filter to the environments of up to 300 other processes through /proc/<pid>/environ.

On disk, it reads up to 60 files in 1.26.1 and 80 in 1.26.2: Azure configuration under .azure/, credentials for pip, npm, Docker and git, .netrc, Hugging Face tokens, Azure DevOps agent .credentials files and .env files.

It also requests new tokens:

  • Azure DevOps (both versions): when SYSTEM_ACCESSTOKEN and SYSTEM_OIDCREQUESTURI are set, it requests an OIDC token for Azure token exchange.
  • GitHub Actions (1.26.2 only): when ACTIONS_ID_TOKEN_REQUEST_URL and its request token are set, it requests OIDC tokens for Azure token exchange and Azure Resource Manager.
  • Azure managed identity (both versions): through IDENTITY_ENDPOINT when it is set, otherwise through the instance metadata service at 169[.]254[.]169[.]254, it requests tokens for 12 Azure resources, including Azure Resource Manager, Key Vault, Storage, Microsoft Graph and Container Registry, and fetches the instance metadata.

How the data leaves

The upload URL is the only encoded value in the code, stored as base64 in a variable named _ENC. The collected data is compressed with zlib, base64-encoded and sent in a single HTTPS POST. The code writes no files and fetches no additional code, and it runs again in every new Python process tree for as long as the package is installed.

Indicators of compromise

IndicatorValueDescription
Malicious versionagent-framework==1.26.1Published 2026-11-17 20:35 UTC
Malicious versionagent-framework==1.26.2Published 2026-11-17 21:08 UTC
Upload URLhxxps://webhook[.]site/d381fd80-ec62-42ad-8f5c-d1b15103c9bb?t=telemetryReceives the collected data
User-Agentaf-runtime-diagnostics/1, runtime-diagnostics/11.26.1, 1.26.2
Startup hookagent_framework_meta.pth, af_runtime_diag.pthIn site-packages
Collectoragent_framework_meta/_telemetry.py, af_runtime_diag.pyIn site-packages
Environment variable_AF_TEL=1Set by the collector
FileSHA256
agent_framework_meta.pth21f28e8517a10ffe431f8d68f5875c85eca4001ae6d118322b0a41873998eb5e
agent_framework_meta/_telemetry.py39fa329f2a93f734b0bb8f5adb203ea3331d1ae479832a5015a54cb17aabd663
af_runtime_diag.pth325e7e9f0ec94e41ad1a1b7a3f18a6b8b5bffece2e2b97b8d3369eb967452f93
af_runtime_diag.py54d885b7d7161c9ed96489c66364c4bfbf635929166843bba10d97d46b5a2e1f
FileSHA1
agent_framework-1.26.1-py3-none-any.whl7a1eaaec6b325f3cee0c8b328a1b5a285c2f1ad9
agent_framework-1.26.2-py3-none-any.whl921ef8764d3f061184dd4d8de61771b07db11ce9

Detection

Each Python environment has its own site-packages, so check all of them on a machine: the system interpreter, virtual environments, Conda environments, pipx installs, container images and CI tool caches. The presence of agent_framework_meta.pth or af_runtime_diag.pth indicates that the malicious startup hook is installed and may execute during normal Python startup. Lockfiles, requirements files and CI install logs that reference agent-framework 1.26.1 or 1.26.2 show where the package was installed. On the network side, look for outbound HTTPS requests to webhook[.]site carrying either User-Agent from the IOC table, and for a Python process requesting managed-identity tokens for a dozen Azure resources in a row.

Remediation

  1. Remove the .pth startup hooks (agent_framework_meta.pth, af_runtime_diag.pth) from affected Python environments before running pip, since invoking pip starts Python and may itself trigger the collector. Then uninstall the malicious releases and remove any remaining collector files.
  2. Reinstall and pin agent-framework==1.26.0 across affected environments. Rebuild container images and clear affected CI caches. This prevents further execution but does not undo any previous credential exposure.
  3. Block the upload URL from the IOC table and consider blocking webhook[.]site on build infrastructure. This can prevent further uploads to the known destination but does not replace searching for the IOCs above and investigating exposure.
  4. Rotate secrets that were in the environment of any process or in the credential files of affected machines.
  5. Review Microsoft Entra ID sign-in and activity logs from November 17, 2026 for unusual use of tokens issued through managed identities and OIDC federation on affected hosts and pipelines. Rotating static secrets does not cover these tokens.

Mend.io coverage

Mend.io has issued 1 MSC advisory covering both malicious versions of agent-framework:

  • MSC-2026-13866

Manage open source risk

Read the report

Recent resources

PHP2Shell in CISA KEV

PHP2Shell is in CISA KEV: why runtime visibility matters

PHP2Shell is in CISA KEV. Who is still exposed, and how to find every build.

Read more
PHP2Shell 2

PHP2Shell: the fix is a runtime upgrade, not a code change

Two critical PHP RCE flaws: who is exposed and how to find every runtime.

Read more
LiteLLM Supply Chain Attack

Compromised LiteLLM 1.107.0 on PyPI Ships a Credential Stealer and Code Loader

LiteLLM 1.107.0 shipped a credential stealer and remote code loader on PyPI.

Read more